|
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-2022 |
|
7
|
|
|
* @package MShop |
|
8
|
|
|
* @subpackage Supplier |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
|
|
12
|
|
|
namespace Aimeos\MShop\Supplier\Item; |
|
13
|
|
|
|
|
14
|
|
|
use \Aimeos\MShop\Common\Item\ListsRef; |
|
|
|
|
|
|
15
|
|
|
use \Aimeos\MShop\Common\Item\AddressRef; |
|
|
|
|
|
|
16
|
|
|
|
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Interface for supplier DTO objects used by the shop. |
|
20
|
|
|
* |
|
21
|
|
|
* @package MShop |
|
22
|
|
|
* @subpackage Supplier |
|
23
|
|
|
*/ |
|
24
|
|
|
class Standard |
|
25
|
|
|
extends \Aimeos\MShop\Common\Item\Base |
|
26
|
|
|
implements \Aimeos\MShop\Supplier\Item\Iface |
|
27
|
|
|
{ |
|
28
|
|
|
use ListsRef\Traits, AddressRef\Traits { |
|
|
|
|
|
|
29
|
|
|
ListsRef\Traits::__clone insteadof AddressRef\Traits; |
|
30
|
|
|
ListsRef\Traits::__clone as __cloneList; |
|
31
|
|
|
AddressRef\Traits::__clone as __cloneAddress; |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Initializes the supplier item object |
|
37
|
|
|
* |
|
38
|
|
|
* @param array $values List of attributes that belong to the supplier item |
|
39
|
|
|
* @param \Aimeos\MShop\Common\Item\Lists\Iface[] $listItems List of list items |
|
40
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface[] $refItems List of referenced items |
|
41
|
|
|
*/ |
|
42
|
|
|
public function __construct( array $values = [], array $listItems = [], array $refItems = [], array $addresses = [] ) |
|
43
|
|
|
{ |
|
44
|
|
|
parent::__construct( 'supplier.', $values ); |
|
45
|
|
|
|
|
46
|
|
|
$this->initListItems( $listItems, $refItems ); |
|
47
|
|
|
$this->initAddressItems( $addresses ); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Creates a deep clone of all objects |
|
53
|
|
|
*/ |
|
54
|
|
|
public function __clone() |
|
55
|
|
|
{ |
|
56
|
|
|
parent::__clone(); |
|
57
|
|
|
$this->__cloneList(); |
|
58
|
|
|
$this->__cloneAddress(); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Returns the label of the supplier item. |
|
64
|
|
|
* |
|
65
|
|
|
* @return string label of the supplier item |
|
66
|
|
|
*/ |
|
67
|
|
|
public function getLabel() : string |
|
68
|
|
|
{ |
|
69
|
|
|
return $this->get( 'supplier.label', '' ); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Sets the new label of the supplier item. |
|
75
|
|
|
* |
|
76
|
|
|
* @param string $value label of the supplier item |
|
77
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item for chaining method calls |
|
78
|
|
|
*/ |
|
79
|
|
|
public function setLabel( string $value ) : \Aimeos\MShop\Supplier\Item\Iface |
|
80
|
|
|
{ |
|
81
|
|
|
return $this->set( 'supplier.label', $value ); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Returns the code of the supplier item. |
|
87
|
|
|
* |
|
88
|
|
|
* @return string Code of the supplier item |
|
89
|
|
|
*/ |
|
90
|
|
|
public function getCode() : string |
|
91
|
|
|
{ |
|
92
|
|
|
return $this->get( 'supplier.code', '' ); |
|
93
|
|
|
} |
|
94
|
|
|
|
|
95
|
|
|
|
|
96
|
|
|
/** |
|
97
|
|
|
* Sets the new code of the supplier item. |
|
98
|
|
|
* |
|
99
|
|
|
* @param string $value Code of the supplier item |
|
100
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item for chaining method calls |
|
101
|
|
|
*/ |
|
102
|
|
|
public function setCode( string $value ) : \Aimeos\MShop\Supplier\Item\Iface |
|
103
|
|
|
{ |
|
104
|
|
|
return $this->set( 'supplier.code', $this->checkCode( $value ) ); |
|
105
|
|
|
} |
|
106
|
|
|
|
|
107
|
|
|
|
|
108
|
|
|
/** |
|
109
|
|
|
* Returns the position of the supplier item. |
|
110
|
|
|
* |
|
111
|
|
|
* @return int Position of the item |
|
112
|
|
|
*/ |
|
113
|
|
|
public function getPosition() : int |
|
114
|
|
|
{ |
|
115
|
|
|
return $this->get( 'supplier.position', 0 ); |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Sets the new position of the supplier item. |
|
121
|
|
|
* |
|
122
|
|
|
* @param int $position Position of the item |
|
123
|
|
|
* @return \Aimeos\MShop\Rule\Item\Iface Rule item for chaining method calls |
|
124
|
|
|
*/ |
|
125
|
|
|
public function setPosition( int $position ) : \Aimeos\MShop\Common\Item\Iface |
|
126
|
|
|
{ |
|
127
|
|
|
return $this->set( 'supplier.position', $position ); |
|
128
|
|
|
} |
|
129
|
|
|
|
|
130
|
|
|
|
|
131
|
|
|
|
|
132
|
|
|
/** |
|
133
|
|
|
* Returns the status of the item |
|
134
|
|
|
* |
|
135
|
|
|
* @return int Status of the item |
|
136
|
|
|
*/ |
|
137
|
|
|
public function getStatus() : int |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->get( 'supplier.status', 1 ); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Sets the new status of the supplier item. |
|
145
|
|
|
* |
|
146
|
|
|
* @param int $value status of the supplier item |
|
147
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item for chaining method calls |
|
148
|
|
|
*/ |
|
149
|
|
|
public function setStatus( int $value ) : \Aimeos\MShop\Common\Item\Iface |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->set( 'supplier.status', $value ); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Returns the item type |
|
157
|
|
|
* |
|
158
|
|
|
* @return string Item type, subtypes are separated by slashes |
|
159
|
|
|
*/ |
|
160
|
|
|
public function getResourceType() : string |
|
161
|
|
|
{ |
|
162
|
|
|
return 'supplier'; |
|
163
|
|
|
} |
|
164
|
|
|
|
|
165
|
|
|
|
|
166
|
|
|
/** |
|
167
|
|
|
* Tests if the item is available based on status, time, language and currency |
|
168
|
|
|
* |
|
169
|
|
|
* @return bool True if available, false if not |
|
170
|
|
|
*/ |
|
171
|
|
|
public function isAvailable() : bool |
|
172
|
|
|
{ |
|
173
|
|
|
return parent::isAvailable() && $this->getStatus() > 0; |
|
174
|
|
|
} |
|
175
|
|
|
|
|
176
|
|
|
|
|
177
|
|
|
/** |
|
178
|
|
|
* Sets the item values from the given array and removes that entries from the list |
|
179
|
|
|
* |
|
180
|
|
|
* @param array &$list Associative list of item keys and their values |
|
181
|
|
|
* @param bool True to set private properties too, false for public only |
|
182
|
|
|
* @return \Aimeos\MShop\Supplier\Item\Iface Supplier item for chaining method calls |
|
183
|
|
|
*/ |
|
184
|
|
|
public function fromArray( array &$list, bool $private = false ) : \Aimeos\MShop\Common\Item\Iface |
|
185
|
|
|
{ |
|
186
|
|
|
$item = parent::fromArray( $list, $private ); |
|
187
|
|
|
|
|
188
|
|
|
foreach( $list as $key => $value ) |
|
189
|
|
|
{ |
|
190
|
|
|
switch( $key ) |
|
191
|
|
|
{ |
|
192
|
|
|
case 'supplier.code': $item = $item->setCode( $value ); break; |
|
193
|
|
|
case 'supplier.label': $item = $item->setLabel( $value ); break; |
|
194
|
|
|
case 'supplier.status': $item = $item->setStatus( (int) $value ); break; |
|
195
|
|
|
case 'supplier.position': $item = $item->setPosition( (int) $value ); break; |
|
196
|
|
|
default: continue 2; |
|
197
|
|
|
} |
|
198
|
|
|
|
|
199
|
|
|
unset( $list[$key] ); |
|
200
|
|
|
} |
|
201
|
|
|
|
|
202
|
|
|
return $item; |
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Returns the item values as array. |
|
208
|
|
|
* |
|
209
|
|
|
* @param bool True to return private properties, false for public only |
|
210
|
|
|
* @return array Associative list of item properties and their values |
|
211
|
|
|
*/ |
|
212
|
|
|
public function toArray( bool $private = false ) : array |
|
213
|
|
|
{ |
|
214
|
|
|
$list = parent::toArray( $private ); |
|
215
|
|
|
|
|
216
|
|
|
$list['supplier.code'] = $this->getCode(); |
|
217
|
|
|
$list['supplier.label'] = $this->getLabel(); |
|
218
|
|
|
$list['supplier.status'] = $this->getStatus(); |
|
219
|
|
|
$list['supplier.position'] = $this->getPosition(); |
|
220
|
|
|
|
|
221
|
|
|
return $list; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
} |
|
225
|
|
|
|
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