Total Complexity | 60 |
Total Lines | 1035 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Complex classes like Standard often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Standard, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
21 | class Standard extends Base |
||
22 | implements \Aimeos\MShop\Catalog\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface |
||
23 | { |
||
24 | private $searchConfig = array( |
||
25 | 'id' => array( |
||
26 | 'code' => 'catalog.id', |
||
27 | 'internalcode' => 'mcat."id"', |
||
28 | 'label' => 'ID', |
||
29 | 'type' => 'integer', |
||
30 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_INT, |
||
31 | 'public' => false, |
||
32 | ), |
||
33 | 'catalog.siteid' => array( |
||
34 | 'code' => 'catalog.siteid', |
||
35 | 'internalcode' => 'mcat."siteid"', |
||
36 | 'label' => 'Site ID', |
||
37 | 'type' => 'string', |
||
38 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
39 | 'public' => false, |
||
40 | ), |
||
41 | 'parentid' => array( |
||
42 | 'code' => 'catalog.parentid', |
||
43 | 'internalcode' => 'mcat."parentid"', |
||
44 | 'label' => 'Parent ID', |
||
45 | 'type' => 'integer', |
||
46 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_INT, |
||
47 | 'public' => false, |
||
48 | ), |
||
49 | 'level' => array( |
||
50 | 'code' => 'catalog.level', |
||
51 | 'internalcode' => 'mcat."level"', |
||
52 | 'label' => 'Tree level', |
||
53 | 'type' => 'integer', |
||
54 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_INT, |
||
55 | 'public' => false, |
||
56 | ), |
||
57 | 'left' => array( |
||
58 | 'code' => 'catalog.left', |
||
59 | 'internalcode' => 'mcat."nleft"', |
||
60 | 'label' => 'Left value', |
||
61 | 'type' => 'integer', |
||
62 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_INT, |
||
63 | 'public' => false, |
||
64 | ), |
||
65 | 'right' => array( |
||
66 | 'code' => 'catalog.right', |
||
67 | 'internalcode' => 'mcat."nright"', |
||
68 | 'label' => 'Right value', |
||
69 | 'type' => 'integer', |
||
70 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_INT, |
||
71 | 'public' => false, |
||
72 | ), |
||
73 | 'label' => array( |
||
74 | 'code' => 'catalog.label', |
||
75 | 'internalcode' => 'mcat."label"', |
||
76 | 'label' => 'Label', |
||
77 | 'type' => 'string', |
||
78 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
79 | ), |
||
80 | 'code' => array( |
||
81 | 'code' => 'catalog.code', |
||
82 | 'internalcode' => 'mcat."code"', |
||
83 | 'label' => 'Code', |
||
84 | 'type' => 'string', |
||
85 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
86 | ), |
||
87 | 'status' => array( |
||
88 | 'code' => 'catalog.status', |
||
89 | 'internalcode' => 'mcat."status"', |
||
90 | 'label' => 'Status', |
||
91 | 'type' => 'integer', |
||
92 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_INT, |
||
93 | ), |
||
94 | 'catalog.url' => array( |
||
95 | 'code' => 'catalog.url', |
||
96 | 'internalcode' => 'mcat."url"', |
||
97 | 'label' => 'URL segment', |
||
98 | 'type' => 'string', |
||
99 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
100 | ), |
||
101 | 'catalog.target' => array( |
||
102 | 'code' => 'catalog.target', |
||
103 | 'internalcode' => 'mcat."target"', |
||
104 | 'label' => 'URL target', |
||
105 | 'type' => 'string', |
||
106 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
107 | ), |
||
108 | 'catalog.config' => array( |
||
109 | 'code' => 'catalog.config', |
||
110 | 'internalcode' => 'mcat."config"', |
||
111 | 'label' => 'Config', |
||
112 | 'type' => 'string', |
||
113 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
114 | 'public' => false, |
||
115 | ), |
||
116 | 'catalog.ctime' => array( |
||
117 | 'label' => 'Create date/time', |
||
118 | 'code' => 'catalog.ctime', |
||
119 | 'internalcode' => 'mcat."ctime"', |
||
120 | 'type' => 'datetime', |
||
121 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
122 | 'public' => false, |
||
123 | ), |
||
124 | 'catalog.mtime' => array( |
||
125 | 'label' => 'Modify date/time', |
||
126 | 'code' => 'catalog.mtime', |
||
127 | 'internalcode' => 'mcat."mtime"', |
||
128 | 'type' => 'datetime', |
||
129 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
130 | 'public' => false, |
||
131 | ), |
||
132 | 'catalog.editor' => array( |
||
133 | 'code' => 'catalog.editor', |
||
134 | 'internalcode' => 'mcat."editor"', |
||
135 | 'label' => 'Editor', |
||
136 | 'type' => 'string', |
||
137 | 'internaltype' => \Aimeos\Base\DB\Statement\Base::PARAM_STR, |
||
138 | 'public' => false, |
||
139 | ), |
||
140 | 'catalog:has' => array( |
||
141 | 'code' => 'catalog:has()', |
||
142 | 'internalcode' => ':site AND :key AND mcatli."id"', |
||
143 | 'internaldeps' => ['LEFT JOIN "mshop_catalog_list" AS mcatli ON ( mcatli."parentid" = mcat."id" )'], |
||
144 | 'label' => 'Catalog has list item, parameter(<domain>[,<list type>[,<reference ID>)]]', |
||
145 | 'type' => 'null', |
||
146 | 'internaltype' => 'null', |
||
147 | 'public' => false, |
||
148 | ), |
||
149 | ); |
||
150 | |||
151 | |||
152 | /** |
||
153 | * Initializes the object. |
||
154 | * |
||
155 | * @param \Aimeos\MShop\ContextIface $context Context object |
||
156 | */ |
||
157 | public function __construct( \Aimeos\MShop\ContextIface $context ) |
||
183 | } |
||
184 | |||
185 | |||
186 | /** |
||
187 | * Removes old entries from the storage. |
||
188 | * |
||
189 | * @param iterable $siteids List of IDs for sites whose entries should be deleted |
||
190 | * @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls |
||
191 | */ |
||
192 | public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface |
||
193 | { |
||
194 | $context = $this->context(); |
||
195 | $config = $context->config(); |
||
196 | $search = $this->object()->filter(); |
||
197 | |||
198 | foreach( $config->get( 'mshop/catalog/manager/submanagers', ['lists'] ) as $domain ) { |
||
199 | $this->object()->getSubManager( $domain )->clear( $siteids ); |
||
200 | } |
||
201 | |||
202 | $conn = $context->db( $this->getResourceName() ); |
||
203 | |||
204 | /** mshop/catalog/manager/cleanup/mysql |
||
205 | * Deletes the categories for the given site from the database |
||
206 | * |
||
207 | * @see mshop/catalog/manager/cleanup/ansi |
||
208 | */ |
||
209 | |||
210 | /** mshop/catalog/manager/cleanup/ansi |
||
211 | * Deletes the categories for the given site from the database |
||
212 | * |
||
213 | * Removes the records matched by the given site ID from the catalog |
||
214 | * database. |
||
215 | * |
||
216 | * The ":siteid" placeholder is replaced by the name and value of the |
||
217 | * site ID column and the given ID or list of IDs. |
||
218 | * |
||
219 | * The SQL statement should conform to the ANSI standard to be |
||
220 | * compatible with most relational database systems. This also |
||
221 | * includes using double quotes for table and column names. |
||
222 | * |
||
223 | * @param string SQL statement for removing the records |
||
224 | * @since 2014.03 |
||
225 | * @category Developer |
||
226 | * @see mshop/catalog/manager/delete/ansi |
||
227 | * @see mshop/catalog/manager/insert/ansi |
||
228 | * @see mshop/catalog/manager/update/ansi |
||
229 | * @see mshop/catalog/manager/newid/ansi |
||
230 | * @see mshop/catalog/manager/search/ansi |
||
231 | * @see mshop/catalog/manager/count/ansi |
||
232 | */ |
||
233 | $path = 'mshop/catalog/manager/cleanup'; |
||
234 | $sql = $this->getSqlConfig( $path ); |
||
235 | |||
236 | $types = array( 'siteid' => \Aimeos\Base\DB\Statement\Base::PARAM_STR ); |
||
237 | $translations = array( 'siteid' => '"siteid"' ); |
||
238 | |||
239 | $search->setConditions( $search->compare( '==', 'siteid', $siteids ) ); |
||
240 | $sql = str_replace( ':siteid', $search->getConditionSource( $types, $translations ), $sql ); |
||
241 | |||
242 | $stmt = $conn->create( $sql ); |
||
243 | $stmt->bind( 1, 0, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
||
244 | $stmt->bind( 2, 0x7FFFFFFF, \Aimeos\Base\DB\Statement\Base::PARAM_INT ); |
||
245 | $stmt->execute()->finish(); |
||
246 | |||
247 | return $this; |
||
248 | } |
||
249 | |||
250 | |||
251 | /** |
||
252 | * Creates a new empty item instance |
||
253 | * |
||
254 | * @param array $values Values the item should be initialized with |
||
255 | * @return \Aimeos\MShop\Catalog\Item\Iface New catalog item object |
||
256 | */ |
||
257 | public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface |
||
258 | { |
||
259 | $values['siteid'] = $this->context()->locale()->getSiteId(); |
||
260 | return $this->createItemBase( $values ); |
||
261 | } |
||
262 | |||
263 | |||
264 | /** |
||
265 | * Creates a filter object. |
||
266 | * |
||
267 | * @param bool|null $default Add default criteria or NULL for relaxed default criteria |
||
268 | * @param bool $site TRUE for adding site criteria to limit items by the site of related items |
||
269 | * @return \Aimeos\Base\Criteria\Iface Returns the filter object |
||
270 | */ |
||
271 | public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\Base\Criteria\Iface |
||
272 | { |
||
273 | return $this->filterBase( 'catalog', $default ); |
||
274 | } |
||
275 | |||
276 | |||
277 | /** |
||
278 | * Removes multiple items. |
||
279 | * |
||
280 | * @param \Aimeos\MShop\Common\Item\Iface|array|string $items List of item objects or IDs of the items |
||
281 | * @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls |
||
282 | */ |
||
283 | public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface |
||
311 | } |
||
312 | |||
313 | |||
314 | /** |
||
315 | * Returns the item specified by its code and domain/type if necessary |
||
316 | * |
||
317 | * @param string $code Code of the item |
||
318 | * @param string[] $ref List of domains to fetch list items and referenced items for |
||
319 | * @param string|null $domain Domain of the item if necessary to identify the item uniquely |
||
320 | * @param string|null $type Type code of the item if necessary to identify the item uniquely |
||
321 | * @param bool|null $default Add default criteria or NULL for relaxed default criteria |
||
322 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog item object |
||
323 | */ |
||
324 | public function find( string $code, array $ref = [], string $domain = null, string $type = null, |
||
325 | ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface |
||
326 | { |
||
327 | return $this->findBase( array( 'catalog.code' => $code ), $ref, $default ); |
||
328 | } |
||
329 | |||
330 | |||
331 | /** |
||
332 | * Returns the item specified by its ID. |
||
333 | * |
||
334 | * @param string $id Unique ID of the catalog item |
||
335 | * @param string[] $ref List of domains to fetch list items and referenced items for |
||
336 | * @param bool|null $default Add default criteria or NULL for relaxed default criteria |
||
337 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog item of the given ID |
||
338 | * @throws \Aimeos\MShop\Exception If item couldn't be found |
||
339 | */ |
||
340 | public function get( string $id, array $ref = [], ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface |
||
341 | { |
||
342 | return $this->getItemBase( 'catalog.id', $id, $ref, $default ); |
||
343 | } |
||
344 | |||
345 | |||
346 | /** |
||
347 | * Returns the available manager types |
||
348 | * |
||
349 | * @param bool $withsub Return also the resource type of sub-managers if true |
||
350 | * @return string[] Type of the manager and submanagers, subtypes are separated by slashes |
||
351 | */ |
||
352 | public function getResourceType( bool $withsub = true ) : array |
||
353 | { |
||
354 | $path = 'mshop/catalog/manager/submanagers'; |
||
355 | return $this->getResourceTypeBase( 'catalog', $path, array( 'lists' ), $withsub ); |
||
356 | } |
||
357 | |||
358 | |||
359 | /** |
||
360 | * Returns the attributes that can be used for searching. |
||
361 | * |
||
362 | * @param bool $withsub Return also attributes of sub-managers if true |
||
363 | * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items |
||
364 | */ |
||
365 | public function getSearchAttributes( bool $withsub = true ) : array |
||
366 | { |
||
367 | /** mshop/catalog/manager/submanagers |
||
368 | * List of manager names that can be instantiated by the catalog manager |
||
369 | * |
||
370 | * Managers provide a generic interface to the underlying storage. |
||
371 | * Each manager has or can have sub-managers caring about particular |
||
372 | * aspects. Each of these sub-managers can be instantiated by its |
||
373 | * parent manager using the getSubManager() method. |
||
374 | * |
||
375 | * The search keys from sub-managers can be normally used in the |
||
376 | * manager as well. It allows you to search for items of the manager |
||
377 | * using the search keys of the sub-managers to further limit the |
||
378 | * retrieved list of items. |
||
379 | * |
||
380 | * @param array List of sub-manager names |
||
381 | * @since 2014.03 |
||
382 | * @category Developer |
||
383 | */ |
||
384 | $path = 'mshop/catalog/manager/submanagers'; |
||
385 | |||
386 | return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub ); |
||
387 | } |
||
388 | |||
389 | |||
390 | /** |
||
391 | * Adds a new item object. |
||
392 | * |
||
393 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Item which should be inserted |
||
394 | * @param string|null $parentId ID of the parent item where the item should be inserted into |
||
395 | * @param string|null $refId ID of the item where the item should be inserted before (null to append) |
||
396 | * @return \Aimeos\MShop\Catalog\Item\Iface $item Updated item including the generated ID |
||
397 | */ |
||
398 | public function insert( \Aimeos\MShop\Catalog\Item\Iface $item, string $parentId = null, |
||
399 | string $refId = null ) : \Aimeos\MShop\Catalog\Item\Iface |
||
400 | { |
||
401 | $this->begin(); |
||
402 | $this->lock(); |
||
403 | |||
404 | try |
||
405 | { |
||
406 | $node = $item->getNode(); |
||
|
|||
407 | $siteid = $this->context()->locale()->getSiteId(); |
||
408 | |||
409 | $this->createTreeManager( $siteid )->insertNode( $node, $parentId, $refId ); |
||
410 | $this->updateUsage( $node->getId(), $item, true ); |
||
411 | $this->unlock(); |
||
412 | $this->commit(); |
||
413 | } |
||
414 | catch( \Exception $e ) |
||
415 | { |
||
416 | $this->unlock(); |
||
417 | $this->rollback(); |
||
418 | throw $e; |
||
419 | } |
||
420 | |||
421 | $item = $this->saveListItems( $item, 'catalog' ); |
||
422 | return $this->saveChildren( $item ); |
||
423 | } |
||
424 | |||
425 | |||
426 | /** |
||
427 | * Moves an existing item to the new parent in the storage. |
||
428 | * |
||
429 | * @param string $id ID of the item that should be moved |
||
430 | * @param string|null $oldParentId ID of the old parent item which currently contains the item that should be removed |
||
431 | * @param string|null $newParentId ID of the new parent item where the item should be moved to |
||
432 | * @param string|null $refId ID of the item where the item should be inserted before (null to append) |
||
433 | * @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls |
||
434 | */ |
||
435 | public function move( string $id, string $oldParentId = null, string $newParentId = null, |
||
459 | } |
||
460 | |||
461 | |||
462 | /** |
||
463 | * Updates an item object. |
||
464 | * |
||
465 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Item object whose data should be saved |
||
466 | * @param bool $fetch True if the new ID should be returned in the item |
||
467 | * @return \Aimeos\MShop\Catalog\Item\Iface $item Updated item including the generated ID |
||
468 | */ |
||
469 | public function saveItem( \Aimeos\MShop\Catalog\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Catalog\Item\Iface |
||
470 | { |
||
471 | if( !$item->isModified() ) |
||
472 | { |
||
473 | $item = $this->saveListItems( $item, 'catalog', $fetch ); |
||
474 | return $this->saveChildren( $item ); |
||
475 | } |
||
476 | |||
477 | $node = $item->getNode(); |
||
478 | $siteid = $this->context()->locale()->getSiteId(); |
||
479 | |||
480 | $this->createTreeManager( $siteid )->saveNode( $node ); |
||
481 | $this->updateUsage( $node->getId(), $item ); |
||
482 | |||
483 | $item = $this->saveListItems( $item, 'catalog', $fetch ); |
||
484 | return $this->saveChildren( $item ); |
||
485 | } |
||
486 | |||
487 | |||
488 | /** |
||
489 | * Searches for all items matching the given critera. |
||
490 | * |
||
491 | * @param \Aimeos\Base\Criteria\Iface $search Search criteria object |
||
492 | * @param string[] $ref List of domains to fetch list items and referenced items for |
||
493 | * @param int|null &$total Number of items that are available in total |
||
494 | * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Catalog\Item\Iface with ids as keys |
||
495 | */ |
||
496 | public function search( \Aimeos\Base\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map |
||
680 | } |
||
681 | |||
682 | |||
683 | /** |
||
684 | * Returns a list of items starting with the given category that are in the path to the root node |
||
685 | * |
||
686 | * @param string $id ID of item to get the path for |
||
687 | * @param string[] $ref List of domains to fetch list items and referenced items for |
||
688 | * @return \Aimeos\Map Associative list of catalog items implementing \Aimeos\MShop\Catalog\Item\Iface with IDs as keys |
||
689 | */ |
||
690 | public function getPath( string $id, array $ref = [] ) : \Aimeos\Map |
||
691 | { |
||
692 | $mode = \Aimeos\MShop\Locale\Manager\Base::SITE_PATH; |
||
693 | $mode = $this->context()->config()->get( 'mshop/catalog/manager/sitemode', $mode ); |
||
694 | |||
695 | if( $mode !== \Aimeos\MShop\Locale\Manager\Base::SITE_ONE ) { |
||
696 | $sitePath = array_reverse( (array) $this->context()->locale()->getSitePath() ); |
||
697 | } else { |
||
698 | $sitePath = [$this->context()->locale()->getSiteId()]; |
||
699 | } |
||
700 | |||
701 | foreach( $sitePath as $siteId ) |
||
702 | { |
||
703 | try { |
||
704 | $path = $this->createTreeManager( $siteId )->getPath( $id ); |
||
705 | } catch( \Exception $e ) { |
||
706 | continue; |
||
707 | } |
||
708 | |||
709 | if( !empty( $path ) ) |
||
710 | { |
||
711 | $itemMap = []; |
||
712 | |||
713 | foreach( $path as $node ) { |
||
714 | $itemMap[$node->getId()] = $node; |
||
715 | } |
||
716 | |||
717 | return $this->buildItems( $itemMap, $ref, 'catalog' ); |
||
718 | } |
||
719 | } |
||
720 | |||
721 | $msg = $this->context()->translate( 'mshop', 'Catalog path for ID "%1$s" not found' ); |
||
722 | throw new \Aimeos\MShop\Catalog\Exception( sprintf( $msg, $id ) ); |
||
723 | } |
||
724 | |||
725 | |||
726 | /** |
||
727 | * Returns a node and its descendants depending on the given resource. |
||
728 | * |
||
729 | * @param string|null $id Retrieve nodes starting from the given ID |
||
730 | * @param string[] List of domains (e.g. text, media, etc.) whose referenced items should be attached to the objects |
||
731 | * @param int $level One of the level constants from \Aimeos\MW\Tree\Manager\Base |
||
732 | * @param \Aimeos\Base\Criteria\Iface|null $criteria Optional criteria object with conditions |
||
733 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog item, maybe with subnodes |
||
734 | */ |
||
735 | public function getTree( string $id = null, array $ref = [], int $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, |
||
736 | \Aimeos\Base\Criteria\Iface $criteria = null ) : \Aimeos\MShop\Catalog\Item\Iface |
||
737 | { |
||
738 | $mode = \Aimeos\MShop\Locale\Manager\Base::SITE_PATH; |
||
739 | $mode = $this->context()->config()->get( 'mshop/catalog/manager/sitemode', $mode ); |
||
740 | |||
741 | if( $mode !== \Aimeos\MShop\Locale\Manager\Base::SITE_ONE ) { |
||
742 | $sitePath = array_reverse( (array) $this->context()->locale()->getSitePath() ); |
||
743 | } else { |
||
744 | $sitePath = [$this->context()->locale()->getSiteId()]; |
||
745 | } |
||
746 | |||
747 | foreach( $sitePath as $siteId ) |
||
748 | { |
||
749 | try { |
||
750 | $node = $this->createTreeManager( $siteId )->getNode( $id, $level, $criteria ); |
||
751 | } catch( \Aimeos\MW\Tree\Exception $e ) { |
||
752 | continue; |
||
753 | } |
||
754 | |||
755 | $listItems = $listItemMap = $refIdMap = []; |
||
756 | $nodeMap = $this->getNodeMap( $node ); |
||
757 | |||
758 | if( count( $ref ) > 0 ) { |
||
759 | $listItems = $this->getListItems( array_keys( $nodeMap ), $ref, 'catalog' ); |
||
760 | } |
||
761 | |||
762 | foreach( $listItems as $listItem ) |
||
763 | { |
||
764 | $domain = $listItem->getDomain(); |
||
765 | $parentid = $listItem->getParentId(); |
||
766 | |||
767 | $listItemMap[$parentid][$domain][$listItem->getId()] = $listItem; |
||
768 | $refIdMap[$domain][$listItem->getRefId()][] = $parentid; |
||
769 | } |
||
770 | |||
771 | $refItemMap = $this->getRefItems( $refIdMap, $ref ); |
||
772 | $nodeid = $node->getId(); |
||
773 | |||
774 | $listItems = []; |
||
775 | if( array_key_exists( $nodeid, $listItemMap ) ) { |
||
776 | $listItems = $listItemMap[$nodeid]; |
||
777 | } |
||
778 | |||
779 | $refItems = []; |
||
780 | if( array_key_exists( $nodeid, $refItemMap ) ) { |
||
781 | $refItems = $refItemMap[$nodeid]; |
||
782 | } |
||
783 | |||
784 | if( $item = $this->applyFilter( $this->createItemBase( [], $listItems, $refItems, [], $node ) ) ) |
||
785 | { |
||
786 | $this->createTree( $node, $item, $listItemMap, $refItemMap ); |
||
787 | return $item; |
||
788 | } |
||
789 | } |
||
790 | |||
791 | $msg = $this->context()->translate( 'mshop', 'No catalog node for ID "%1$s"' ); |
||
792 | throw new \Aimeos\MShop\Catalog\Exception( sprintf( $msg, $id ) ); |
||
793 | } |
||
794 | |||
795 | |||
796 | /** |
||
797 | * Creates a new extension manager in the domain. |
||
798 | * |
||
799 | * @param string $manager Name of the sub manager type |
||
800 | * @param string|null $name Name of the implementation, will be from configuration (or Default) |
||
801 | * @return \Aimeos\MShop\Common\Manager\Iface Manager extending the domain functionality |
||
802 | */ |
||
803 | public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface |
||
804 | { |
||
805 | return $this->getSubManagerBase( 'catalog', $manager, $name ); |
||
806 | } |
||
807 | |||
808 | |||
809 | /** |
||
810 | * Saves the children of the given node |
||
811 | * |
||
812 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item object incl. child items |
||
813 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog item with saved child items |
||
814 | */ |
||
815 | protected function saveChildren( \Aimeos\MShop\Catalog\Item\Iface $item ) : \Aimeos\MShop\Catalog\Item\Iface |
||
841 | } |
||
842 | |||
843 | |||
844 | /** |
||
845 | * Locks the catalog table against modifications from other connections |
||
846 | * |
||
847 | * @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls |
||
848 | */ |
||
849 | protected function lock() : \Aimeos\MShop\Catalog\Manager\Iface |
||
850 | { |
||
851 | /** mshop/catalog/manager/lock/mysql |
||
852 | * SQL statement for locking the catalog table |
||
853 | * |
||
854 | * @see mshop/catalog/manager/lock/ansi |
||
855 | */ |
||
856 | |||
857 | /** mshop/catalog/manager/lock/ansi |
||
858 | * SQL statement for locking the catalog table |
||
859 | * |
||
860 | * Updating the nested set of categories in the catalog table requires locking |
||
861 | * the whole table to avoid data corruption. This statement will be followed by |
||
862 | * insert or update statements and closed by an unlock statement. |
||
863 | * |
||
864 | * @param string Lock SQL statement |
||
865 | * @since 2019.04 |
||
866 | * @category Developer |
||
867 | */ |
||
868 | $path = 'mshop/catalog/manager/lock'; |
||
869 | |||
870 | if( ( $sql = $this->getSqlConfig( $path ) ) !== $path ) |
||
871 | { |
||
872 | $conn = $this->context()->db( $this->getResourceName() ); |
||
873 | $conn->create( $sql )->execute()->finish(); |
||
874 | } |
||
875 | |||
876 | return $this; |
||
877 | } |
||
878 | |||
879 | |||
880 | /** |
||
881 | * Unlocks the catalog table for modifications from other connections |
||
882 | * |
||
883 | * @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls |
||
884 | */ |
||
885 | protected function unlock() : \Aimeos\MShop\Catalog\Manager\Iface |
||
886 | { |
||
887 | /** mshop/catalog/manager/unlock/mysql |
||
888 | * SQL statement for unlocking the catalog table |
||
889 | * |
||
890 | * @see mshop/catalog/manager/unlock/ansi |
||
891 | */ |
||
892 | |||
893 | /** mshop/catalog/manager/unlock/ansi |
||
894 | * SQL statement for unlocking the catalog table |
||
895 | * |
||
896 | * Updating the nested set of categories in the catalog table requires locking |
||
897 | * the whole table to avoid data corruption. This statement will be executed |
||
898 | * after the table is locked and insert or update statements have been sent to |
||
899 | * the database. |
||
900 | * |
||
901 | * @param string Lock SQL statement |
||
902 | * @since 2019.04 |
||
903 | * @category Developer |
||
904 | */ |
||
905 | $path = 'mshop/catalog/manager/unlock'; |
||
906 | |||
907 | if( ( $sql = $this->getSqlConfig( $path ) ) !== $path ) |
||
908 | { |
||
909 | $conn = $this->context()->db( $this->getResourceName() ); |
||
910 | $conn->create( $sql )->execute()->finish(); |
||
911 | } |
||
912 | |||
913 | return $this; |
||
914 | } |
||
915 | |||
916 | |||
917 | /** |
||
918 | * Updates the usage information of a node. |
||
919 | * |
||
920 | * @param string $id Id of the record |
||
921 | * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item |
||
922 | * @param bool $case True if the record shoud be added or false for an update |
||
923 | * @return \Aimeos\MShop\Catalog\Manager\Iface Manager object for chaining method calls |
||
924 | */ |
||
925 | private function updateUsage( string $id, \Aimeos\MShop\Catalog\Item\Iface $item, |
||
1056 | } |
||
1057 | } |
||
1058 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.