1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2018 |
6
|
|
|
* @package Controller |
7
|
|
|
* @subpackage Frontend |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Customer\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for customer frontend controller decorators |
16
|
|
|
* |
17
|
|
|
* @package Controller |
18
|
|
|
* @subpackage Frontend |
19
|
|
|
*/ |
20
|
|
|
abstract class Base |
21
|
|
|
extends \Aimeos\Controller\Frontend\Base |
22
|
|
|
implements \Aimeos\Controller\Frontend\Common\Decorator\Iface, \Aimeos\Controller\Frontend\Customer\Iface |
23
|
|
|
{ |
24
|
|
|
private $controller; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initializes the controller decorator. |
29
|
|
|
* |
30
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32
|
|
|
*/ |
33
|
|
|
public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
34
|
|
|
{ |
35
|
|
|
parent::__construct( $context ); |
36
|
|
|
|
37
|
|
|
$iface = \Aimeos\Controller\Frontend\Customer\Iface::class; |
38
|
|
|
$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Passes unknown methods to wrapped objects. |
44
|
|
|
* |
45
|
|
|
* @param string $name Name of the method |
46
|
|
|
* @param array $param List of method parameter |
47
|
|
|
* @return mixed Returns the value of the called method |
48
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
49
|
|
|
*/ |
50
|
|
|
public function __call( $name, array $param ) |
51
|
|
|
{ |
52
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Adds and returns a new customer item object |
58
|
|
|
* |
59
|
|
|
* @param array $values Values added to the customer item (new or existing) like "customer.code" |
60
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
61
|
|
|
* @since 2019.04 |
62
|
|
|
*/ |
63
|
|
|
public function add( array $values ) |
64
|
|
|
{ |
65
|
|
|
$this->controller->add( $values ); |
66
|
|
|
return $this; |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* Adds the given address item to the customer object (not yet stored) |
72
|
|
|
* |
73
|
|
|
* @param \Aimeos\MShop\Common\Item\Address\Iface $item Address item to add |
74
|
|
|
* @param integer|null $pos Position (key) in the list of address items or null to add the item at the end |
75
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
76
|
|
|
* @since 2019.04 |
77
|
|
|
*/ |
78
|
|
|
public function addAddressItem( \Aimeos\MShop\Common\Item\Address\Iface $item, $position = null ) |
79
|
|
|
{ |
80
|
|
|
$this->controller->addAddressItem( $item, $position ); |
81
|
|
|
return $this; |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Adds the given list item to the customer object (not yet stored) |
87
|
|
|
* |
88
|
|
|
* @param string $domain Domain name the referenced item belongs to |
89
|
|
|
* @param \Aimeos\MShop\Common\Item\Lists\Iface $item List item to add |
90
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface|null $refItem Referenced item to add or null if list item contains refid value |
91
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
92
|
|
|
* @since 2019.04 |
93
|
|
|
*/ |
94
|
|
|
public function addListItem( $domain, \Aimeos\MShop\Common\Item\Lists\Iface $item, \Aimeos\MShop\Common\Item\Iface $refItem = null ) |
95
|
|
|
{ |
96
|
|
|
$this->controller->addListItem( $domain, $item, $refItem ); |
97
|
|
|
return $this; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
|
101
|
|
|
/** |
102
|
|
|
* Adds the given property item to the customer object (not yet stored) |
103
|
|
|
* |
104
|
|
|
* @param \Aimeos\MShop\Common\Item\Property\Iface $item Property item to add |
105
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
106
|
|
|
* @since 2019.04 |
107
|
|
|
*/ |
108
|
|
|
public function addPropertyItem( \Aimeos\MShop\Common\Item\Property\Iface $item ) |
109
|
|
|
{ |
110
|
|
|
$this->controller->addPropertyItem( $item ); |
111
|
|
|
return $this; |
112
|
|
|
} |
113
|
|
|
|
114
|
|
|
|
115
|
|
|
/** |
116
|
|
|
* Creates a new address item object pre-filled with the given values |
117
|
|
|
* |
118
|
|
|
* @return \Aimeos\MShop\Customer\Item\Address\Iface Address item |
119
|
|
|
* @since 2019.04 |
120
|
|
|
*/ |
121
|
|
|
public function createAddressItem( array $values = [] ) |
122
|
|
|
{ |
123
|
|
|
return $this->controller->createAddressItem( $values ); |
124
|
|
|
} |
125
|
|
|
|
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Creates a new list item object pre-filled with the given values |
129
|
|
|
* |
130
|
|
|
* @return \Aimeos\MShop\Common\Item\Lists\Iface List item |
131
|
|
|
* @since 2019.04 |
132
|
|
|
*/ |
133
|
|
|
public function createListItem( array $values = [] ) |
134
|
|
|
{ |
135
|
|
|
return $this->controller->createListItem( $values ); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
|
139
|
|
|
/** |
140
|
|
|
* Creates a new property item object pre-filled with the given values |
141
|
|
|
* |
142
|
|
|
* @return \Aimeos\MShop\Common\Item\Property\Iface Property item |
143
|
|
|
* @since 2019.04 |
144
|
|
|
*/ |
145
|
|
|
public function createPropertyItem( array $values = [] ) |
146
|
|
|
{ |
147
|
|
|
return $this->controller->createPropertyItem( $values ); |
148
|
|
|
} |
149
|
|
|
|
150
|
|
|
|
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Deletes a customer item that belongs to the current authenticated user |
154
|
|
|
* |
155
|
|
|
* @param string $id Unique customer ID |
156
|
|
|
* @since 2017.04 |
157
|
|
|
*/ |
158
|
|
|
public function delete() |
159
|
|
|
{ |
160
|
|
|
$this->controller->delete(); |
161
|
|
|
return $this; |
162
|
|
|
} |
163
|
|
|
|
164
|
|
|
|
165
|
|
|
/** |
166
|
|
|
* Removes the given address item from the customer object (not yet stored) |
167
|
|
|
* |
168
|
|
|
* @param \Aimeos\MShop\Common\Item\Address\Iface $item Address item to remove |
169
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
170
|
|
|
*/ |
171
|
|
|
public function deleteAddressItem( \Aimeos\MShop\Common\Item\Address\Iface $item ) |
172
|
|
|
{ |
173
|
|
|
$this->controller->deleteAddressItem( $item ); |
174
|
|
|
return $this; |
175
|
|
|
} |
176
|
|
|
|
177
|
|
|
|
178
|
|
|
/** |
179
|
|
|
* Removes the given list item from the customer object (not yet stored) |
180
|
|
|
* |
181
|
|
|
* @param string $domain Domain name the referenced item belongs to |
182
|
|
|
* @param \Aimeos\MShop\Common\Item\Lists\Iface $item List item to remove |
183
|
|
|
* @param \Aimeos\MShop\Common\Item\Iface|null $refItem Referenced item to remove or null if only list item should be removed |
184
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
185
|
|
|
*/ |
186
|
|
|
public function deleteListItem( $domain, \Aimeos\MShop\Common\Item\Lists\Iface $listItem, \Aimeos\MShop\Common\Item\Iface $refItem = null ) |
187
|
|
|
{ |
188
|
|
|
$this->controller->deleteListItem( $domain, $listItem, $refItem ); |
189
|
|
|
return $this; |
190
|
|
|
} |
191
|
|
|
|
192
|
|
|
|
193
|
|
|
/** |
194
|
|
|
* Removes the given property item from the customer object (not yet stored) |
195
|
|
|
* |
196
|
|
|
* @param \Aimeos\MShop\Common\Item\Property\Iface $item Property item to remove |
197
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
198
|
|
|
*/ |
199
|
|
|
public function deletePropertyItem( \Aimeos\MShop\Common\Item\Property\Iface $item ) |
200
|
|
|
{ |
201
|
|
|
$this->controller->deletePropertyItem( $item ); |
202
|
|
|
return $this; |
203
|
|
|
} |
204
|
|
|
|
205
|
|
|
|
206
|
|
|
/** |
207
|
|
|
* Returns the customer item for the given code |
208
|
|
|
* |
209
|
|
|
* This method doesn't check if the customer item belongs to the logged in user! |
210
|
|
|
* |
211
|
|
|
* @param string|null $code Unique customer code |
212
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item |
213
|
|
|
* @since 2019.04 |
214
|
|
|
*/ |
215
|
|
|
public function find( $code ) |
216
|
|
|
{ |
217
|
|
|
return $this->controller->find( $code ); |
218
|
|
|
} |
219
|
|
|
|
220
|
|
|
|
221
|
|
|
/** |
222
|
|
|
* Returns the customer item for the current authenticated user |
223
|
|
|
* |
224
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item |
225
|
|
|
* @since 2019.04 |
226
|
|
|
*/ |
227
|
|
|
public function get() |
228
|
|
|
{ |
229
|
|
|
return $this->controller->get(); |
230
|
|
|
} |
231
|
|
|
|
232
|
|
|
|
233
|
|
|
/** |
234
|
|
|
* Adds or updates the modified customer item in the storage |
235
|
|
|
* |
236
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
237
|
|
|
* @since 2019.04 |
238
|
|
|
*/ |
239
|
|
|
public function store() |
240
|
|
|
{ |
241
|
|
|
$this->controller->store(); |
242
|
|
|
return $this; |
243
|
|
|
} |
244
|
|
|
|
245
|
|
|
|
246
|
|
|
/** |
247
|
|
|
* Sets the domains that will be used when working with the customer item |
248
|
|
|
* |
249
|
|
|
* @param array $domains Domain names of the referenced items that should be fetched too |
250
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Customer controller for fluent interface |
251
|
|
|
* @since 2019.04 |
252
|
|
|
*/ |
253
|
|
|
public function uses( array $domains ) |
254
|
|
|
{ |
255
|
|
|
$this->controller->uses( $domains ); |
256
|
|
|
return $this; |
257
|
|
|
} |
258
|
|
|
|
259
|
|
|
|
260
|
|
|
/** |
261
|
|
|
* Returns the frontend controller |
262
|
|
|
* |
263
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Frontend controller object |
264
|
|
|
* @since 2017.04 |
265
|
|
|
*/ |
266
|
|
|
protected function getController() |
267
|
|
|
{ |
268
|
|
|
return $this->controller; |
269
|
|
|
} |
270
|
|
|
} |
271
|
|
|
|