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