|
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-2025 |
|
7
|
|
|
* @package MShop |
|
8
|
|
|
* @subpackage Catalog |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace Aimeos\MShop\Catalog\Item; |
|
13
|
|
|
|
|
14
|
|
|
use \Aimeos\MShop\Common\Item\Config; |
|
|
|
|
|
|
15
|
|
|
use \Aimeos\MShop\Common\Item\ListsRef; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Generic interface for catalog items. |
|
20
|
|
|
* |
|
21
|
|
|
* @package MShop |
|
22
|
|
|
* @subpackage Catalog |
|
23
|
|
|
*/ |
|
24
|
|
|
class Standard |
|
25
|
|
|
extends \Aimeos\MShop\Common\Item\Base |
|
26
|
|
|
implements \Aimeos\MShop\Catalog\Item\Iface |
|
27
|
|
|
{ |
|
28
|
|
|
use Config\Traits, ListsRef\Traits { |
|
|
|
|
|
|
29
|
|
|
ListsRef\Traits::__clone as __cloneList; |
|
30
|
|
|
ListsRef\Traits::getName as getNameList; |
|
31
|
|
|
} |
|
32
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
private \Aimeos\MW\Tree\Node\Iface $node; |
|
35
|
|
|
private array $deletedItems = []; |
|
36
|
|
|
private array $children; |
|
37
|
|
|
|
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Initializes the catalog item. |
|
41
|
|
|
* |
|
42
|
|
|
* @param \Aimeos\MW\Tree\Node\Iface $node Tree node |
|
43
|
|
|
* @param array $values Assoicative list of key/value pairs |
|
44
|
|
|
* @param \Aimeos\MShop\Catalog\Item\Iface[] $children List of children of the item |
|
45
|
|
|
* @param \Aimeos\MShop\Common\Item\Lists\Iface[] $listItems List of list items |
|
46
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items |
|
47
|
|
|
*/ |
|
48
|
|
|
public function __construct( \Aimeos\MW\Tree\Node\Iface $node, array $values = [], array $children = [], |
|
49
|
|
|
array $listItems = [], array $refItems = [] ) |
|
50
|
|
|
{ |
|
51
|
|
|
parent::__construct( '', $values ); |
|
52
|
|
|
|
|
53
|
|
|
map( $children )->implements( \Aimeos\MShop\Catalog\Item\Iface::class, true ); |
|
54
|
|
|
|
|
55
|
|
|
$this->initListItems( $listItems, $refItems ); |
|
56
|
|
|
$this->children = $children; |
|
57
|
|
|
$this->node = $node; |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Clones internal objects of the catalog item. |
|
63
|
|
|
*/ |
|
64
|
|
|
public function __clone() |
|
65
|
|
|
{ |
|
66
|
|
|
parent::__clone(); |
|
67
|
|
|
$this->__cloneList(); |
|
68
|
|
|
$this->node = clone $this->node; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Tests if the item property for the given name is available |
|
74
|
|
|
* |
|
75
|
|
|
* @param string $name Name of the property |
|
76
|
|
|
* @return bool True if the property exists, false if not |
|
77
|
|
|
*/ |
|
78
|
|
|
public function __isset( string $name ) : bool |
|
79
|
|
|
{ |
|
80
|
|
|
if( $name === 'children' ) { |
|
81
|
|
|
return true; |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
return parent::__isset( $name ) ?: isset( $this->node->$name ); |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
|
|
88
|
|
|
/** |
|
89
|
|
|
* Returns the item property for the given name |
|
90
|
|
|
* |
|
91
|
|
|
* @param string $name Name of the property |
|
92
|
|
|
* @param mixed $default Default value if property is unknown |
|
93
|
|
|
* @return mixed|null Property value or default value if property is unknown |
|
94
|
|
|
*/ |
|
95
|
|
|
public function get( string $name, $default = null ) |
|
96
|
|
|
{ |
|
97
|
|
|
if( $name === 'children' ) { |
|
98
|
|
|
return $this->children; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
if( ( $value = parent::get( $name ) ) !== null ) { |
|
102
|
|
|
return $value; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
return $this->node->$name ?? $default; |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Returns the unique ID of the node. |
|
111
|
|
|
* |
|
112
|
|
|
* @return string|null Unique ID of the node |
|
113
|
|
|
*/ |
|
114
|
|
|
public function getId() : ?string |
|
115
|
|
|
{ |
|
116
|
|
|
return $this->node->getId(); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
|
|
120
|
|
|
/** |
|
121
|
|
|
* Sets the unique ID of the node. |
|
122
|
|
|
* |
|
123
|
|
|
* @param string|null $id Unique ID of the node |
|
124
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
125
|
|
|
*/ |
|
126
|
|
|
public function setId( ?string $id = null ) : \Aimeos\MShop\Common\Item\Iface |
|
127
|
|
|
{ |
|
128
|
|
|
$this->node->setId( $id ); |
|
129
|
|
|
return $this; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
|
|
133
|
|
|
/** |
|
134
|
|
|
* Returns the site ID of the item. |
|
135
|
|
|
* |
|
136
|
|
|
* @return string Site ID of the item |
|
137
|
|
|
*/ |
|
138
|
|
|
public function getSiteId() : string |
|
139
|
|
|
{ |
|
140
|
|
|
return (string) $this->node->siteid; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
|
|
144
|
|
|
/** |
|
145
|
|
|
* Returns the internal name of the item. |
|
146
|
|
|
* |
|
147
|
|
|
* @return string Name of the item |
|
148
|
|
|
*/ |
|
149
|
|
|
public function getLabel() : string |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->node->getLabel(); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Sets the new internal name of the item. |
|
157
|
|
|
* |
|
158
|
|
|
* @param string $name New name of the item |
|
159
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
160
|
|
|
*/ |
|
161
|
|
|
public function setLabel( string $name ) : \Aimeos\MShop\Common\Item\Tree\Iface |
|
162
|
|
|
{ |
|
163
|
|
|
$this->node->setLabel( $name ); |
|
164
|
|
|
return $this; |
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Returns the localized text type of the item or the internal label if no name is available. |
|
170
|
|
|
* |
|
171
|
|
|
* @param string $type Text type to be returned |
|
172
|
|
|
* @param string|null $langId Two letter ISO Language code of the text |
|
173
|
|
|
* @return string Specified text type or label of the item |
|
174
|
|
|
*/ |
|
175
|
|
|
public function getName( string $type = 'name', ?string $langId = null ) : string |
|
176
|
|
|
{ |
|
177
|
|
|
$name = $this->getNameList( $type, $langId ); |
|
178
|
|
|
|
|
179
|
|
|
if( $type === 'url' && $name === $this->getLabel() ) { |
|
180
|
|
|
return $this->getUrl(); |
|
181
|
|
|
} |
|
182
|
|
|
|
|
183
|
|
|
return $name; |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
|
|
187
|
|
|
/** |
|
188
|
|
|
* Returns the URL segment for the catalog item. |
|
189
|
|
|
* |
|
190
|
|
|
* @return string URL segment of the catalog item |
|
191
|
|
|
*/ |
|
192
|
|
|
public function getUrl() : string |
|
193
|
|
|
{ |
|
194
|
|
|
return (string) ( $this->node->url ?: \Aimeos\Base\Str::slug( $this->getLabel() ) ); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
|
|
198
|
|
|
/** |
|
199
|
|
|
* Sets a new URL segment for the catalog. |
|
200
|
|
|
* |
|
201
|
|
|
* @param string|null $url New URL segment of the catalog item |
|
202
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
203
|
|
|
*/ |
|
204
|
|
|
public function setUrl( ?string $url ) : \Aimeos\MShop\Catalog\Item\Iface |
|
205
|
|
|
{ |
|
206
|
|
|
$this->node->url = (string) $url; |
|
207
|
|
|
return $this; |
|
208
|
|
|
} |
|
209
|
|
|
|
|
210
|
|
|
|
|
211
|
|
|
/** |
|
212
|
|
|
* Returns the config property of the catalog. |
|
213
|
|
|
* |
|
214
|
|
|
* @return array Returns the config of the catalog node |
|
215
|
|
|
*/ |
|
216
|
|
|
public function getConfig() : array |
|
217
|
|
|
{ |
|
218
|
|
|
return (array) $this->get( 'config', [] ); |
|
219
|
|
|
} |
|
220
|
|
|
|
|
221
|
|
|
|
|
222
|
|
|
/** |
|
223
|
|
|
* Sets the config property of the catalog item. |
|
224
|
|
|
* |
|
225
|
|
|
* @param array $config Configuration to be set for the catalog node |
|
226
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
227
|
|
|
*/ |
|
228
|
|
|
public function setConfig( array $config ) : \Aimeos\MShop\Common\Item\Iface |
|
229
|
|
|
{ |
|
230
|
|
|
if( !$this->compareConfig( $this->getConfig(), $config ) ) { |
|
231
|
|
|
$this->set( 'config', $config ); |
|
232
|
|
|
} |
|
233
|
|
|
|
|
234
|
|
|
return $this; |
|
235
|
|
|
} |
|
236
|
|
|
|
|
237
|
|
|
|
|
238
|
|
|
/** |
|
239
|
|
|
* Returns the code of the item. |
|
240
|
|
|
* |
|
241
|
|
|
* @return string Code of the item |
|
242
|
|
|
*/ |
|
243
|
|
|
public function getCode() : string |
|
244
|
|
|
{ |
|
245
|
|
|
return $this->node->getCode(); |
|
246
|
|
|
} |
|
247
|
|
|
|
|
248
|
|
|
|
|
249
|
|
|
/** |
|
250
|
|
|
* Sets the new code of the item. |
|
251
|
|
|
* |
|
252
|
|
|
* @param string $code New code of the item |
|
253
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
254
|
|
|
*/ |
|
255
|
|
|
public function setCode( string $code ) : \Aimeos\MShop\Common\Item\Tree\Iface |
|
256
|
|
|
{ |
|
257
|
|
|
$this->node->setCode( \Aimeos\Utils::code( $code ) ); |
|
258
|
|
|
return $this; |
|
259
|
|
|
} |
|
260
|
|
|
|
|
261
|
|
|
|
|
262
|
|
|
/** |
|
263
|
|
|
* Returns the status of the item. |
|
264
|
|
|
* |
|
265
|
|
|
* @return int Greater than zero if enabled, zero or negative values if disabled |
|
266
|
|
|
*/ |
|
267
|
|
|
public function getStatus() : int |
|
268
|
|
|
{ |
|
269
|
|
|
return $this->node->getStatus(); |
|
270
|
|
|
} |
|
271
|
|
|
|
|
272
|
|
|
|
|
273
|
|
|
/** |
|
274
|
|
|
* Sets the new status of the item. |
|
275
|
|
|
* |
|
276
|
|
|
* @param int $status True if enabled, false if not |
|
277
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
278
|
|
|
*/ |
|
279
|
|
|
public function setStatus( int $status ) : \Aimeos\MShop\Common\Item\Iface |
|
280
|
|
|
{ |
|
281
|
|
|
$this->node->setStatus( $status ); |
|
282
|
|
|
return $this; |
|
283
|
|
|
} |
|
284
|
|
|
|
|
285
|
|
|
|
|
286
|
|
|
/** |
|
287
|
|
|
* Returns the URL target specific for that category |
|
288
|
|
|
* |
|
289
|
|
|
* @return string URL target specific for that category |
|
290
|
|
|
*/ |
|
291
|
|
|
public function getTarget() : string |
|
292
|
|
|
{ |
|
293
|
|
|
return (string) $this->node->target; |
|
294
|
|
|
} |
|
295
|
|
|
|
|
296
|
|
|
|
|
297
|
|
|
/** |
|
298
|
|
|
* Sets a new URL target specific for that category |
|
299
|
|
|
* |
|
300
|
|
|
* @param string $value New URL target specific for that category |
|
301
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
302
|
|
|
*/ |
|
303
|
|
|
public function setTarget( ?string $value ) : \Aimeos\MShop\Catalog\Item\Iface |
|
304
|
|
|
{ |
|
305
|
|
|
$this->node->target = (string) $value; |
|
306
|
|
|
return $this; |
|
307
|
|
|
} |
|
308
|
|
|
|
|
309
|
|
|
|
|
310
|
|
|
/** |
|
311
|
|
|
* Returns modify date/time of the order item base product. |
|
312
|
|
|
* |
|
313
|
|
|
* @return string|null Returns modify date/time of the order base item |
|
314
|
|
|
*/ |
|
315
|
|
|
public function getTimeModified() : ?string |
|
316
|
|
|
{ |
|
317
|
|
|
return $this->node->mtime; |
|
318
|
|
|
} |
|
319
|
|
|
|
|
320
|
|
|
|
|
321
|
|
|
/** |
|
322
|
|
|
* Returns the create date of the item. |
|
323
|
|
|
* |
|
324
|
|
|
* @return string|null ISO date in YYYY-MM-DD hh:mm:ss format |
|
325
|
|
|
*/ |
|
326
|
|
|
public function getTimeCreated() : ?string |
|
327
|
|
|
{ |
|
328
|
|
|
return $this->node->ctime; |
|
329
|
|
|
} |
|
330
|
|
|
|
|
331
|
|
|
|
|
332
|
|
|
/** |
|
333
|
|
|
* Returns the editor code of editor who created/modified the item at last. |
|
334
|
|
|
* |
|
335
|
|
|
* @return string Editor who created/modified the item at last |
|
336
|
|
|
*/ |
|
337
|
|
|
public function editor() : string |
|
338
|
|
|
{ |
|
339
|
|
|
return (string) $this->node->editor; |
|
340
|
|
|
} |
|
341
|
|
|
|
|
342
|
|
|
|
|
343
|
|
|
/** |
|
344
|
|
|
* Adds a child node to this node. |
|
345
|
|
|
* |
|
346
|
|
|
* @param \Aimeos\MShop\Common\Item\Tree\Iface $item Child node to add |
|
347
|
|
|
* @return \Aimeos\MShop\Common\Item\Tree\Iface Tree item for chaining method calls |
|
348
|
|
|
*/ |
|
349
|
|
|
public function addChild( \Aimeos\MShop\Common\Item\Tree\Iface $item ) : \Aimeos\MShop\Common\Item\Tree\Iface |
|
350
|
|
|
{ |
|
351
|
|
|
// don't set the modified flag as it's only for the values |
|
352
|
|
|
$this->children[] = $item; |
|
353
|
|
|
|
|
354
|
|
|
return $this; |
|
355
|
|
|
} |
|
356
|
|
|
|
|
357
|
|
|
|
|
358
|
|
|
/** |
|
359
|
|
|
* Removes a child node from this node. |
|
360
|
|
|
* |
|
361
|
|
|
* @param \Aimeos\MShop\Common\Item\Tree\Iface $item Child node to remove |
|
362
|
|
|
* @return \Aimeos\MShop\Common\Item\Tree\Iface Tree item for chaining method calls |
|
363
|
|
|
*/ |
|
364
|
|
|
public function deleteChild( \Aimeos\MShop\Common\Item\Tree\Iface $item ) : \Aimeos\MShop\Common\Item\Tree\Iface |
|
365
|
|
|
{ |
|
366
|
|
|
foreach( $this->children as $idx => $child ) |
|
367
|
|
|
{ |
|
368
|
|
|
if( $child === $item ) |
|
369
|
|
|
{ |
|
370
|
|
|
$this->deletedItems[] = $item; |
|
371
|
|
|
unset( $this->children[$idx] ); |
|
372
|
|
|
} |
|
373
|
|
|
} |
|
374
|
|
|
|
|
375
|
|
|
return $this; |
|
376
|
|
|
} |
|
377
|
|
|
|
|
378
|
|
|
|
|
379
|
|
|
/** |
|
380
|
|
|
* Returns a child of this node identified by its index. |
|
381
|
|
|
* |
|
382
|
|
|
* @param int $index Index of child node |
|
383
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Selected node |
|
384
|
|
|
*/ |
|
385
|
|
|
public function getChild( int $index ) : \Aimeos\MShop\Common\Item\Tree\Iface |
|
386
|
|
|
{ |
|
387
|
|
|
if( isset( $this->children[$index] ) ) { |
|
388
|
|
|
return $this->children[$index]; |
|
389
|
|
|
} |
|
390
|
|
|
|
|
391
|
|
|
throw new \Aimeos\MShop\Catalog\Exception( sprintf( 'Child node with index "%1$d" not available', $index ) ); |
|
392
|
|
|
} |
|
393
|
|
|
|
|
394
|
|
|
|
|
395
|
|
|
/** |
|
396
|
|
|
* Returns all children of this node. |
|
397
|
|
|
* |
|
398
|
|
|
* @return \Aimeos\Map Numerically indexed list of children implementing \Aimeos\MShop\Catalog\Item\Iface |
|
399
|
|
|
*/ |
|
400
|
|
|
public function getChildren() : \Aimeos\Map |
|
401
|
|
|
{ |
|
402
|
|
|
return map( $this->children ); |
|
403
|
|
|
} |
|
404
|
|
|
|
|
405
|
|
|
|
|
406
|
|
|
/** |
|
407
|
|
|
* Returns the deleted children. |
|
408
|
|
|
* |
|
409
|
|
|
* @return \Aimeos\Map List of removed children implementing \Aimeos\MShop\Catalog\Item\Iface |
|
410
|
|
|
*/ |
|
411
|
|
|
public function getChildrenDeleted() : \Aimeos\Map |
|
412
|
|
|
{ |
|
413
|
|
|
return map( $this->deletedItems ); |
|
414
|
|
|
} |
|
415
|
|
|
|
|
416
|
|
|
|
|
417
|
|
|
/** |
|
418
|
|
|
* Tests if a node has children. |
|
419
|
|
|
* |
|
420
|
|
|
* @return bool True if node has children, false if not |
|
421
|
|
|
*/ |
|
422
|
|
|
public function hasChildren() : bool |
|
423
|
|
|
{ |
|
424
|
|
|
if( count( $this->children ) > 0 ) { |
|
425
|
|
|
return true; |
|
426
|
|
|
} |
|
427
|
|
|
|
|
428
|
|
|
return $this->node->hasChildren(); |
|
429
|
|
|
} |
|
430
|
|
|
|
|
431
|
|
|
|
|
432
|
|
|
/** |
|
433
|
|
|
* Returns the internal node. |
|
434
|
|
|
* |
|
435
|
|
|
* For internal use only! |
|
436
|
|
|
* |
|
437
|
|
|
* @return \Aimeos\MW\Tree\Node\Iface Internal node object |
|
438
|
|
|
*/ |
|
439
|
|
|
public function getNode() : \Aimeos\MW\Tree\Node\Iface |
|
440
|
|
|
{ |
|
441
|
|
|
return $this->node; |
|
442
|
|
|
} |
|
443
|
|
|
|
|
444
|
|
|
|
|
445
|
|
|
/** |
|
446
|
|
|
* Returns the level of the item in the tree |
|
447
|
|
|
* |
|
448
|
|
|
* For internal use only! |
|
449
|
|
|
* |
|
450
|
|
|
* @return int Level of the item starting with "0" for the root node |
|
451
|
|
|
*/ |
|
452
|
|
|
public function getLevel() : int |
|
453
|
|
|
{ |
|
454
|
|
|
return $this->node->level ?: 0; |
|
455
|
|
|
} |
|
456
|
|
|
|
|
457
|
|
|
|
|
458
|
|
|
/** |
|
459
|
|
|
* Returns the ID of the parent category |
|
460
|
|
|
* |
|
461
|
|
|
* For internal use only! |
|
462
|
|
|
* |
|
463
|
|
|
* @return string|null Unique ID of the parent category |
|
464
|
|
|
*/ |
|
465
|
|
|
public function getParentId() : ?string |
|
466
|
|
|
{ |
|
467
|
|
|
return $this->node->parentid; |
|
468
|
|
|
} |
|
469
|
|
|
|
|
470
|
|
|
|
|
471
|
|
|
/** |
|
472
|
|
|
* Tests if the item is available based on status, time, language and currency |
|
473
|
|
|
* |
|
474
|
|
|
* @return bool True if available, false if not |
|
475
|
|
|
*/ |
|
476
|
|
|
public function isAvailable() : bool |
|
477
|
|
|
{ |
|
478
|
|
|
return parent::isAvailable() && $this->getStatus() > 0; |
|
479
|
|
|
} |
|
480
|
|
|
|
|
481
|
|
|
|
|
482
|
|
|
/** |
|
483
|
|
|
* Checks, whether this node was modified. |
|
484
|
|
|
* |
|
485
|
|
|
* @return bool True if the content of the node is modified, false if not |
|
486
|
|
|
*/ |
|
487
|
|
|
public function isModified() : bool |
|
488
|
|
|
{ |
|
489
|
|
|
return parent::isModified() || $this->node->isModified(); |
|
490
|
|
|
} |
|
491
|
|
|
|
|
492
|
|
|
|
|
493
|
|
|
/* |
|
494
|
|
|
* Sets the item values from the given array and removes that entries from the list |
|
495
|
|
|
* |
|
496
|
|
|
* @param array &$list Associative list of item keys and their values |
|
497
|
|
|
* @param bool True to set private properties too, false for public only |
|
498
|
|
|
* @return \Aimeos\MShop\Catalog\Item\Iface Catalog item for chaining method calls |
|
499
|
|
|
*/ |
|
500
|
|
|
public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface |
|
501
|
|
|
{ |
|
502
|
|
|
$item = parent::fromArray( $list, $private ); |
|
503
|
|
|
|
|
504
|
|
|
foreach( $list as $key => $value ) |
|
505
|
|
|
{ |
|
506
|
|
|
switch( $key ) |
|
507
|
|
|
{ |
|
508
|
|
|
case 'catalog.url': $item->setUrl( $value ); break; |
|
509
|
|
|
case 'catalog.code': $item->setCode( $value ); break; |
|
510
|
|
|
case 'catalog.label': $item->setLabel( $value ); break; |
|
511
|
|
|
case 'catalog.target': $item->setTarget( $value ); break; |
|
512
|
|
|
case 'catalog.status': $item->setStatus( (int) $value ); break; |
|
513
|
|
|
case 'catalog.config': $item->setConfig( (array) $value ); break; |
|
514
|
|
|
case 'catalog.id': !$private ?: $item->setId( $value ); break; |
|
515
|
|
|
default: continue 2; |
|
516
|
|
|
} |
|
517
|
|
|
|
|
518
|
|
|
unset( $list[$key] ); |
|
519
|
|
|
} |
|
520
|
|
|
|
|
521
|
|
|
return $item; |
|
522
|
|
|
} |
|
523
|
|
|
|
|
524
|
|
|
|
|
525
|
|
|
/** |
|
526
|
|
|
* Returns the public values of the node as array. |
|
527
|
|
|
* |
|
528
|
|
|
* @param bool True to return private properties, false for public only |
|
529
|
|
|
* @return array Assciative list of key/value pairs |
|
530
|
|
|
*/ |
|
531
|
|
|
public function toArray( bool $private = false ) : array |
|
532
|
|
|
{ |
|
533
|
|
|
$list = [ |
|
534
|
|
|
'catalog.url' => $this->getUrl(), |
|
535
|
|
|
'catalog.code' => $this->getCode(), |
|
536
|
|
|
'catalog.label' => $this->getLabel(), |
|
537
|
|
|
'catalog.config' => $this->getConfig(), |
|
538
|
|
|
'catalog.status' => $this->getStatus(), |
|
539
|
|
|
'catalog.target' => $this->getTarget(), |
|
540
|
|
|
'catalog.hasChildren' => $this->hasChildren(), |
|
541
|
|
|
]; |
|
542
|
|
|
|
|
543
|
|
|
if( $private === true ) |
|
544
|
|
|
{ |
|
545
|
|
|
$list['catalog.id'] = $this->getId(); |
|
546
|
|
|
$list['catalog.level'] = $this->getLevel(); |
|
547
|
|
|
$list['catalog.siteid'] = $this->getSiteId(); |
|
548
|
|
|
$list['catalog.parentid'] = $this->getParentId(); |
|
549
|
|
|
$list['catalog.ctime'] = $this->getTimeCreated(); |
|
550
|
|
|
$list['catalog.mtime'] = $this->getTimeModified(); |
|
551
|
|
|
$list['catalog.editor'] = $this->editor(); |
|
552
|
|
|
} |
|
553
|
|
|
|
|
554
|
|
|
return $list; |
|
555
|
|
|
} |
|
556
|
|
|
|
|
557
|
|
|
|
|
558
|
|
|
/** |
|
559
|
|
|
* Returns the node and its children as list |
|
560
|
|
|
* |
|
561
|
|
|
* @return \Aimeos\Map List of IDs as keys and items implementing \Aimeos\MShop\Catalog\Item\Iface |
|
562
|
|
|
*/ |
|
563
|
|
|
public function toList() : \Aimeos\Map |
|
564
|
|
|
{ |
|
565
|
|
|
$list = map( [$this->getId() => $this] ); |
|
566
|
|
|
|
|
567
|
|
|
foreach( $this->getChildren() as $child ) { |
|
568
|
|
|
$list = $list->union( $child->toList() ); |
|
569
|
|
|
} |
|
570
|
|
|
|
|
571
|
|
|
return $list; |
|
572
|
|
|
} |
|
573
|
|
|
} |
|
574
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths