• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-core / 4f8b7e8d-5595-43b2-ba5c-df9921830178

17 May 2026 07:32AM UTC coverage: 92.581%. Remained the same
4f8b7e8d-5595-43b2-ba5c-df9921830178

push

circleci

aimeos
Fixed PHPStan issues

896 of 980 new or added lines in 165 files covered. (91.43%)

35 existing lines in 29 files now uncovered.

9734 of 10514 relevant lines covered (92.58%)

80.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.59
/src/MAdmin/Job/Manager/Standard.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2026
7
 * @package MAdmin
8
 * @subpackage Job
9
 */
10

11

12
namespace Aimeos\MAdmin\Job\Manager;
13

14

15
/**
16
 * Default job manager implementation.
17
 *
18
 * @package MAdmin
19
 * @subpackage Job
20
 */
21
class Standard
22
        extends \Aimeos\MAdmin\Common\Manager\Base
23
        implements \Aimeos\MAdmin\Job\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
24
{
25
        /** madmin/job/manager/name
26
         * Class name of the used job manager implementation
27
         *
28
         * Each default manager can be replace by an alternative imlementation.
29
         * To use this implementation, you have to set the last part of the class
30
         * name as configuration value so the manager factory knows which class it
31
         * has to instantiate.
32
         *
33
         * For example, if the name of the default class is
34
         *
35
         *  \Aimeos\MShop\Job\Manager\Standard
36
         *
37
         * and you want to replace it with your own version named
38
         *
39
         *  \Aimeos\MShop\Job\Manager\Mymanager
40
         *
41
         * then you have to set the this configuration option:
42
         *
43
         *  madmin/job/manager/name = Mymanager
44
         *
45
         * The value is the last part of your own class name and it's case sensitive,
46
         * so take care that the configuration value is exactly named like the last
47
         * part of the class name.
48
         *
49
         * The allowed characters of the class name are A-Z, a-z and 0-9. No other
50
         * characters are possible! You should always start the last part of the class
51
         * name with an upper case character and continue only with lower case characters
52
         * or numbers. Avoid chamel case names like "MyManager"!
53
         *
54
         * @type string Last part of the class name
55
         * @since 2014.03
56
         */
57

58
        /** madmin/job/manager/decorators/excludes
59
         * Excludes decorators added by the "common" option from the job manager
60
         *
61
         * Decorators extend the functionality of a class by adding new aspects
62
         * (e.g. log what is currently done), executing the methods of the underlying
63
         * class only in certain conditions (e.g. only for logged in users) or
64
         * modify what is returned to the caller.
65
         *
66
         * This option allows you to remove a decorator added via
67
         * "madmin/common/manager/decorators/default" before they are wrapped
68
         * around the job manager.
69
         *
70
         *  madmin/job/manager/decorators/excludes = array( 'decorator1' )
71
         *
72
         * This would remove the decorator named "decorator1" from the list of
73
         * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
74
         * "madmin/common/manager/decorators/default" for the job manager.
75
         *
76
         * @type array List of decorator names
77
         * @since 2014.03
78
         * @see madmin/common/manager/decorators/default
79
         * @see madmin/job/manager/decorators/global
80
         * @see madmin/job/manager/decorators/local
81
         */
82

83
        /** madmin/job/manager/decorators/global
84
         * Adds a list of globally available decorators only to the job manager
85
         *
86
         * Decorators extend the functionality of a class by adding new aspects
87
         * (e.g. log what is currently done), executing the methods of the underlying
88
         * class only in certain conditions (e.g. only for logged in users) or
89
         * modify what is returned to the caller.
90
         *
91
         * This option allows you to wrap global decorators
92
         * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the job manager.
93
         *
94
         *  madmin/job/manager/decorators/global = array( 'decorator1' )
95
         *
96
         * This would add the decorator named "decorator1" defined by
97
         * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the job controller.
98
         *
99
         * @type array List of decorator names
100
         * @since 2014.03
101
         * @see madmin/common/manager/decorators/default
102
         * @see madmin/job/manager/decorators/excludes
103
         * @see madmin/job/manager/decorators/local
104
         */
105

106
        /** madmin/job/manager/decorators/local
107
         * Adds a list of local decorators only to the job manager
108
         *
109
         * Decorators extend the functionality of a class by adding new aspects
110
         * (e.g. log what is currently done), executing the methods of the underlying
111
         * class only in certain conditions (e.g. only for logged in users) or
112
         * modify what is returned to the caller.
113
         *
114
         * This option allows you to wrap local decorators
115
         * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the job manager.
116
         *
117
         *  madmin/job/manager/decorators/local = array( 'decorator2' )
118
         *
119
         * This would add the decorator named "decorator2" defined by
120
         * "\Aimeos\MShop\Common\Manager\Decorator\Decorator2" only to the job
121
         * controller.
122
         *
123
         * @type array List of decorator names
124
         * @since 2014.03
125
         * @see madmin/common/manager/decorators/default
126
         * @see madmin/job/manager/decorators/excludes
127
         * @see madmin/job/manager/decorators/global
128
         */
129

130

131
        private array $searchConfig = array(
132
                'job.id' => array(
133
                        'code' => 'job.id',
134
                        'internalcode' => 'majob."id"',
135
                        'label' => 'ID',
136
                        'type' => 'int',
137
                ),
138
                'job.siteid' => array(
139
                        'code' => 'job.siteid',
140
                        'internalcode' => 'majob."siteid"',
141
                        'label' => 'Site ID',
142
                        'public' => false,
143
                ),
144
                'job.label' => array(
145
                        'code' => 'job.label',
146
                        'internalcode' => 'majob."label"',
147
                        'label' => 'Label',
148
                ),
149
                'job.status' => array(
150
                        'code' => 'job.status',
151
                        'internalcode' => 'majob."status"',
152
                        'label' => 'Status',
153
                        'type' => 'int',
154
                ),
155
                'job.path' => array(
156
                        'code' => 'job.path',
157
                        'internalcode' => 'majob."path"',
158
                        'label' => 'Generated file path',
159
                ),
160
                'job.ctime' => array(
161
                        'code' => 'job.ctime',
162
                        'internalcode' => 'majob."ctime"',
163
                        'label' => 'Create date/time',
164
                        'type' => 'datetime',
165
                ),
166
                'job.mtime' => array(
167
                        'code' => 'job.mtime',
168
                        'internalcode' => 'majob."mtime"',
169
                        'label' => 'Modify date/time',
170
                        'type' => 'datetime',
171
                ),
172
                'job.editor' => array(
173
                        'code' => 'job.editor',
174
                        'internalcode' => 'majob."editor"',
175
                        'label' => 'Editor',
176
                ),
177
        );
178

179

180
        /**
181
         * Initializes the object.
182
         *
183
         * @param \Aimeos\MShop\ContextIface $context Context object
184
         */
185
        public function __construct( \Aimeos\MShop\ContextIface $context )
186
        {
187
                parent::__construct( $context );
12✔
188

189
                /** madmin/job/manager/resource
190
                 * Name of the database connection resource to use
191
                 *
192
                 * You can configure a different database connection for each data domain
193
                 * and if no such connection name exists, the "db" connection will be used.
194
                 * It's also possible to use the same database connection for different
195
                 * data domains by configuring the same connection name using this setting.
196
                 *
197
                 * @type string Database connection name
198
                 * @since 2023.04
199
                 */
200
                $this->setResourceName( (string) $context->config()->get( 'madmin/job/manager/resource', 'db-job' ) );
12✔
201
        }
202

203

204
        /**
205
         * Removes old entries from the storage.
206
         *
207
         * @param iterable $siteids List of IDs for sites whose entries should be deleted
208
         * @return static Manager object for chaining method calls
209
         */
210
        public function clear( iterable $siteids ) : static
211
        {
212
                $path = 'madmin/job/manager/submanagers';
4✔
213
                foreach( $this->context()->config()->get( $path, [] ) as $domain ) {
4✔
NEW
214
                        $this->object()->getSubManager( (string) $domain )->clear( $siteids );
×
215
                }
216

217
                return $this->clearBase( $siteids, 'madmin/job/manager/delete' );
4✔
218
        }
219

220

221
        /**
222
         * Creates a new empty item instance
223
         *
224
         * @param array $values Values the item should be initialized with
225
         * @return \Aimeos\MAdmin\Job\Item\Iface New job item object
226
         */
227
        public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
228
        {
229
                $values['job.siteid'] = $values['job.siteid'] ?? $this->context()->locale()->getSiteId();
2✔
230
                return $this->createItemBase( $values );
2✔
231
        }
232

233

234
        /**
235
         * Creates a filter object.
236
         *
237
         * @param bool|null $default Add default criteria or NULL for relaxed default criteria
238
         * @param bool $site TRUE for adding site criteria to limit items by the site of related items
239
         * @return \Aimeos\Base\Criteria\Iface Returns the filter object
240
         */
241
        public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\Base\Criteria\Iface
242
        {
243
                return $this->filterBase( 'job', $default );
4✔
244
        }
245

246

247
        /**
248
         * Adds a new job to the storage.
249
         *
250
         * @param \Aimeos\MAdmin\Job\Item\Iface $item Job item that should be saved to the storage
251
         * @param bool $fetch True if the new ID should be returned in the item
252
         * @return \Aimeos\MAdmin\Job\Item\Iface Updated item including the generated ID
253
         */
254
        protected function saveItem( \Aimeos\MAdmin\Job\Item\Iface $item, bool $fetch = true ) : \Aimeos\MAdmin\Job\Item\Iface
255
        {
256
                if( !$item->isModified() ) {
1✔
257
                        return $item;
×
258
                }
259

260
                $context = $this->context();
1✔
261
                $conn = $context->db( $this->getResourceName() );
1✔
262

263
                $id = $item->getId();
1✔
264
                $columns = $this->getSaveColumns();
1✔
265

266
                if( $id === null )
1✔
267
                {
268
                        /** madmin/job/manager/insert/mysql
269
                         * Inserts a new job record into the database table
270
                         *
271
                         * @see madmin/job/manager/insert/ansi
272
                         */
273

274
                        /** madmin/job/manager/insert/ansi
275
                         * Inserts a new job record into the database table
276
                         *
277
                         * Items with no ID yet (i.e. the ID is NULL) will be created in
278
                         * the database and the newly created ID retrieved afterwards
279
                         * using the "newid" SQL statement.
280
                         *
281
                         * The SQL statement must be a string suitable for being used as
282
                         * prepared statement. It must include question marks for binding
283
                         * the values from the job item to the statement before they are
284
                         * sent to the database server. The number of question marks must
285
                         * be the same as the number of columns listed in the INSERT
286
                         * statement. The order of the columns must correspond to the
287
                         * order in the save() method, so the correct values are
288
                         * bound to the columns.
289
                         *
290
                         * The SQL statement should conform to the ANSI standard to be
291
                         * compatible with most relational database systems. This also
292
                         * includes using double quotes for table and column names.
293
                         *
294
                         * @type string SQL statement for inserting records
295
                         * @since 2014.03
296
                         * @see madmin/job/manager/update/ansi
297
                         * @see madmin/job/manager/newid/ansi
298
                         * @see madmin/job/manager/delete/ansi
299
                         * @see madmin/job/manager/search/ansi
300
                         * @see madmin/job/manager/count/ansi
301
                         */
302
                        $path = 'madmin/job/manager/insert';
1✔
303
                        $sql = $this->addSqlColumns( array_keys( $columns ), (string) $this->getSqlConfig( $path ) );
1✔
304
                }
305
                else
306
                {
307
                        /** madmin/job/manager/update/mysql
308
                         * Updates an existing job record in the database
309
                         *
310
                         * @see madmin/job/manager/update/ansi
311
                         */
312

313
                        /** madmin/job/manager/update/ansi
314
                         * Updates an existing job record in the database
315
                         *
316
                         * Items which already have an ID (i.e. the ID is not NULL) will
317
                         * be updated in the database.
318
                         *
319
                         * The SQL statement must be a string suitable for being used as
320
                         * prepared statement. It must include question marks for binding
321
                         * the values from the job item to the statement before they are
322
                         * sent to the database server. The order of the columns must
323
                         * correspond to the order in the save() method, so the
324
                         * correct values are bound to the columns.
325
                         *
326
                         * The SQL statement should conform to the ANSI standard to be
327
                         * compatible with most relational database systems. This also
328
                         * includes using double quotes for table and column names.
329
                         *
330
                         * @type string SQL statement for updating records
331
                         * @since 2014.03
332
                         * @see madmin/job/manager/insert/ansi
333
                         * @see madmin/job/manager/newid/ansi
334
                         * @see madmin/job/manager/delete/ansi
335
                         * @see madmin/job/manager/search/ansi
336
                         * @see madmin/job/manager/count/ansi
337
                         */
338
                        $path = 'madmin/job/manager/update';
1✔
339
                        $sql = $this->addSqlColumns( array_keys( $columns ), (string) $this->getSqlConfig( $path ), false );
1✔
340
                }
341

342
                $idx = 1;
1✔
343
                $stmt = $this->getCachedStatement( $conn, $path, $sql );
1✔
344

345
                foreach( $columns as $entry ) {
1✔
346
                        $stmt->bind( $idx++, $item->get( $entry->getCode() ), \Aimeos\Base\Criteria\SQL::type( $entry->getType() ) );
×
347
                }
348

349
                $stmt->bind( $idx++, $item->getLabel() );
1✔
350
                $stmt->bind( $idx++, $item->getPath() );
1✔
351
                $stmt->bind( $idx++, $item->getStatus(), \Aimeos\Base\DB\Statement\Base::PARAM_INT );
1✔
352
                $stmt->bind( $idx++, $context->editor() );
1✔
353
                $stmt->bind( $idx++, $context->datetime() );
1✔
354

355
                if( $id !== null ) {
1✔
356
                        $stmt->bind( $idx++, $context->locale()->getSiteId() . '%' );
1✔
357
                        $stmt->bind( $idx++, $id, \Aimeos\Base\DB\Statement\Base::PARAM_INT );
1✔
358
                } else {
359
                        $stmt->bind( $idx++, $context->locale()->getSiteId() );
1✔
360
                        $stmt->bind( $idx++, $context->datetime() );
1✔
361
                }
362

363
                $stmt->execute()->finish();
1✔
364

365
                if( $id === null && $fetch === true )
1✔
366
                {
367
                        /** madmin/job/manager/newid/mysql
368
                         * Retrieves the ID generated by the database when inserting a new record
369
                         *
370
                         * @see madmin/job/manager/newid/ansi
371
                         */
372

373
                        /** madmin/job/manager/newid/ansi
374
                         * Retrieves the ID generated by the database when inserting a new record
375
                         *
376
                         * As soon as a new record is inserted into the database table,
377
                         * the database server generates a new and unique identifier for
378
                         * that record. This ID can be used for retrieving, updating and
379
                         * deleting that specific record from the table again.
380
                         *
381
                         * For MySQL:
382
                         *  SELECT LAST_INSERT_ID()
383
                         * For PostgreSQL:
384
                         *  SELECT currval('seq_majob_id')
385
                         * For SQL Server:
386
                         *  SELECT SCOPE_IDENTITY()
387
                         * For Oracle:
388
                         *  SELECT "seq_majob_id".CURRVAL FROM DUAL
389
                         *
390
                         * There's no way to retrive the new ID by a SQL statements that
391
                         * fits for most database servers as they implement their own
392
                         * specific way.
393
                         *
394
                         * @type string SQL statement for retrieving the last inserted record ID
395
                         * @since 2014.03
396
                         * @see madmin/job/manager/insert/ansi
397
                         * @see madmin/job/manager/update/ansi
398
                         * @see madmin/job/manager/delete/ansi
399
                         * @see madmin/job/manager/search/ansi
400
                         * @see madmin/job/manager/count/ansi
401
                         */
402
                        $id = $this->newId( $conn, 'madmin/job/manager/newid' );
1✔
403
                }
404

405
                $item->setId( $id ); // so item is no longer modified
1✔
406

407
                return $item;
1✔
408
        }
409

410

411
        /**
412
         * Removes multiple items.
413
         *
414
         * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
415
         * @return static Manager object for chaining method calls
416
         */
417
        public function delete( $itemIds ) : static
418
        {
419
                /** madmin/job/manager/delete/mysql
420
                 * Deletes the items matched by the given IDs from the database
421
                 *
422
                 * @see madmin/job/manager/delete/ansi
423
                 */
424

425
                /** madmin/job/manager/delete/ansi
426
                 * Deletes the items matched by the given IDs from the database
427
                 *
428
                 * Removes the records specified by the given IDs from the job database.
429
                 * The records must be from the site that is configured via the
430
                 * context item.
431
                 *
432
                 * The ":cond" placeholder is replaced by the name of the ID column and
433
                 * the given ID or list of IDs while the site ID is bound to the question
434
                 * mark.
435
                 *
436
                 * The SQL statement should conform to the ANSI standard to be
437
                 * compatible with most relational database systems. This also
438
                 * includes using double quotes for table and column names.
439
                 *
440
                 * @type string SQL statement for deleting items
441
                 * @since 2014.03
442
                 * @see madmin/job/manager/insert/ansi
443
                 * @see madmin/job/manager/update/ansi
444
                 * @see madmin/job/manager/newid/ansi
445
                 * @see madmin/job/manager/search/ansi
446
                 * @see madmin/job/manager/count/ansi
447
                 */
448
                $path = 'madmin/job/manager/delete';
2✔
449

450
                return $this->deleteItemsBase( $itemIds, $path );
2✔
451
        }
452

453

454
        /**
455
         * Creates the job object for the given job ID.
456
         *
457
         * @param string $id Job ID to fetch job object for
458
         * @param string[] $ref List of domains to fetch list items and referenced items for
459
         * @param bool|null $default Add default criteria or NULL for relaxed default criteria
460
         * @return \Aimeos\MAdmin\Job\Item\Iface Returns the job item of the given id
461
         * @throws \Aimeos\MAdmin\Job\Exception If item couldn't be found
462
         */
463
        public function get( string $id, array $ref = [], ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
464
        {
465
                $criteria = $this->object()->filter( $default );
2✔
466
                $expr = [
2✔
467
                        $criteria->compare( '==', 'job.id', $id ),
2✔
468
                        $criteria->getConditions()
2✔
469
                ];
2✔
470
                // @phpstan-ignore argument.type
471
                $criteria->setConditions( $criteria->and( $expr ) );
2✔
472

473
                if( ( $item = $this->object()->search( $criteria, $ref )->first() ) ) {
2✔
474
                        // @phpstan-ignore return.type
475
                        return $item;
2✔
476
                }
477

478
                $msg = $this->context()->translate( 'mshop', 'Job with ID "%1$s" not found' );
1✔
479
                throw new \Aimeos\MAdmin\Job\Exception( sprintf( $msg, $id ) );
1✔
480
        }
481

482

483
        /**
484
         * Search for jobs based on the given criteria.
485
         *
486
         * @param \Aimeos\Base\Criteria\Iface $search Search object containing the conditions
487
         * @param string[] $ref List of domains to fetch list items and referenced items for
488
         * @type int &$total Number of items that are available in total
489
         * @return \Aimeos\Map List of items implementing \Aimeos\MAdmin\Job\Item\Iface with ids as keys
490
         */
491
        public function search( \Aimeos\Base\Criteria\Iface $search, array $ref = [], ?int &$total = null ) : \Aimeos\Map
492
        {
493
                $items = [];
3✔
494
                $context = $this->context();
3✔
495
                $logger = $context->logger();
3✔
496
                $conn = $context->db( $this->getResourceName() );
3✔
497

498
                $required = array( 'job' );
3✔
499
                $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ONE;
3✔
500

501
                /** madmin/job/manager/search/mysql
502
                 * Retrieves the records matched by the given criteria in the database
503
                 *
504
                 * @see madmin/job/manager/search/ansi
505
                 */
506

507
                /** madmin/job/manager/search/ansi
508
                 * Retrieves the records matched by the given criteria in the database
509
                 *
510
                 * Fetches the records matched by the given criteria from the job
511
                 * database. The records must be from one of the sites that are
512
                 * configured via the context item. If the current site is part of
513
                 * a tree of sites, the SELECT statement can retrieve all records
514
                 * from the current site and the complete sub-tree of sites.
515
                 *
516
                 * As the records can normally be limited by criteria from sub-managers,
517
                 * their tables must be joined in the SQL context. This is done by
518
                 * using the "internaldeps" property from the definition of the ID
519
                 * column of the sub-managers. These internal dependencies specify
520
                 * the JOIN between the tables and the used columns for joining. The
521
                 * ":joins" placeholder is then replaced by the JOIN strings from
522
                 * the sub-managers.
523
                 *
524
                 * To limit the records matched, conditions can be added to the given
525
                 * criteria object. It can contain comparisons like column names that
526
                 * must match specific values which can be combined by AND, OR or NOT
527
                 * operators. The resulting string of SQL conditions replaces the
528
                 * ":cond" placeholder before the statement is sent to the database
529
                 * server.
530
                 *
531
                 * If the records that are retrieved should be ordered by one or more
532
                 * columns, the generated string of column / sort direction pairs
533
                 * replaces the ":order" placeholder. Columns of
534
                 * sub-managers can also be used for ordering the result set but then
535
                 * no index can be used.
536
                 *
537
                 * The number of returned records can be limited and can start at any
538
                 * number between the begining and the end of the result set. For that
539
                 * the ":size" and ":start" placeholders are replaced by the
540
                 * corresponding values from the criteria object. The default values
541
                 * are 0 for the start and 100 for the size value.
542
                 *
543
                 * The SQL statement should conform to the ANSI standard to be
544
                 * compatible with most relational database systems. This also
545
                 * includes using double quotes for table and column names.
546
                 *
547
                 * @type string SQL statement for searching items
548
                 * @since 2014.03
549
                 * @see madmin/job/manager/insert/ansi
550
                 * @see madmin/job/manager/update/ansi
551
                 * @see madmin/job/manager/newid/ansi
552
                 * @see madmin/job/manager/delete/ansi
553
                 * @see madmin/job/manager/count/ansi
554
                 */
555
                $cfgPathSearch = 'madmin/job/manager/search';
3✔
556

557
                /** madmin/job/manager/count/mysql
558
                 * Counts the number of records matched by the given criteria in the database
559
                 *
560
                 * @see madmin/job/manager/count/ansi
561
                 */
562

563
                /** madmin/job/manager/count/ansi
564
                 * Counts the number of records matched by the given criteria in the database
565
                 *
566
                 * Counts all records matched by the given criteria from the job
567
                 * database. The records must be from one of the sites that are
568
                 * configured via the context item. If the current site is part of
569
                 * a tree of sites, the statement can count all records from the
570
                 * current site and the complete sub-tree of sites.
571
                 *
572
                 * As the records can normally be limited by criteria from sub-managers,
573
                 * their tables must be joined in the SQL context. This is done by
574
                 * using the "internaldeps" property from the definition of the ID
575
                 * column of the sub-managers. These internal dependencies specify
576
                 * the JOIN between the tables and the used columns for joining. The
577
                 * ":joins" placeholder is then replaced by the JOIN strings from
578
                 * the sub-managers.
579
                 *
580
                 * To limit the records matched, conditions can be added to the given
581
                 * criteria object. It can contain comparisons like column names that
582
                 * must match specific values which can be combined by AND, OR or NOT
583
                 * operators. The resulting string of SQL conditions replaces the
584
                 * ":cond" placeholder before the statement is sent to the database
585
                 * server.
586
                 *
587
                 * Both, the strings for ":joins" and for ":cond" are the same as for
588
                 * the "search" SQL statement.
589
                 *
590
                 * Contrary to the "search" statement, it doesn't return any records
591
                 * but instead the number of records that have been found. As counting
592
                 * thousands of records can be a long running task, the maximum number
593
                 * of counted records is limited for performance reasons.
594
                 *
595
                 * The SQL statement should conform to the ANSI standard to be
596
                 * compatible with most relational database systems. This also
597
                 * includes using double quotes for table and column names.
598
                 *
599
                 * @type string SQL statement for counting items
600
                 * @since 2014.03
601
                 * @see madmin/job/manager/insert/ansi
602
                 * @see madmin/job/manager/update/ansi
603
                 * @see madmin/job/manager/newid/ansi
604
                 * @see madmin/job/manager/delete/ansi
605
                 * @see madmin/job/manager/search/ansi
606
                 */
607
                $cfgPathCount = 'madmin/job/manager/count';
3✔
608

609
                $results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total, $level );
3✔
610

611
                while( $row = $results->fetch() )
3✔
612
                {
613
                        if( $item = $this->applyFilter( $this->createItemBase( $row ) ) ) {
3✔
614
                                $items[$row['job.id']] = $item;
3✔
615
                        }
616
                }
617

618
                return map( $items );
3✔
619
        }
620

621

622
        /**
623
         * Returns the attributes that can be used for searching.
624
         *
625
         * @param bool $withsub Return also attributes of sub-managers if true
626
         * @return \Aimeos\Base\Criteria\Attribute\Iface[] Returns a list of attributes
627
         */
628
        public function getSearchAttributes( bool $withsub = true ) : array
629
        {
630
                /** madmin/job/manager/submanagers
631
                 * List of manager names that can be instantiated by the job manager
632
                 *
633
                 * Managers provide a generic interface to the underlying storage.
634
                 * Each manager has or can have sub-managers caring about particular
635
                 * aspects. Each of these sub-managers can be instantiated by its
636
                 * parent manager using the getSubManager() method.
637
                 *
638
                 * The search keys from sub-managers can be normally used in the
639
                 * manager as well. It allows you to search for items of the manager
640
                 * using the search keys of the sub-managers to further limit the
641
                 * retrieved list of items.
642
                 *
643
                 * @type array List of sub-manager names
644
                 * @since 2014.03
645
                 */
646
                $path = 'madmin/job/manager/submanagers';
4✔
647

648
                return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub );
4✔
649
        }
650

651

652
        /**
653
         * Returns a new manager for job extensions
654
         *
655
         * @param string $manager Name of the sub manager type in lower case
656
         * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
657
         * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g stock, tags, locations, etc.
658
         */
659
        public function getSubManager( string $manager, ?string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
660
        {
661
                return $this->getSubManagerBase( 'job', $manager, $name );
1✔
662
        }
663

664

665
        /**
666
         * Create new admin job item object initialized with given parameters.
667
         *
668
         * @param array $values Associative list of key/value pairs of a job
669
         * @return \Aimeos\MAdmin\Job\Item\Iface New job item
670
         */
671
        protected function createItemBase( array $values = [] ) : \Aimeos\MAdmin\Job\Item\Iface
672
        {
673
                return new \Aimeos\MAdmin\Job\Item\Standard( $values );
4✔
674
        }
675
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc