|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
|
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017 |
|
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
|
|
|
$iface = '\Aimeos\Controller\Frontend\Customer\Iface'; |
|
36
|
|
|
if( !( $controller instanceof $iface ) ) |
|
37
|
|
|
{ |
|
38
|
|
|
$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
|
39
|
|
|
throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$this->controller = $controller; |
|
43
|
|
|
|
|
44
|
|
|
parent::__construct( $context ); |
|
45
|
|
|
} |
|
46
|
|
|
|
|
47
|
|
|
|
|
48
|
|
|
/** |
|
49
|
|
|
* Passes unknown methods to wrapped objects. |
|
50
|
|
|
* |
|
51
|
|
|
* @param string $name Name of the method |
|
52
|
|
|
* @param array $param List of method parameter |
|
53
|
|
|
* @return mixed Returns the value of the called method |
|
54
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
|
55
|
|
|
*/ |
|
56
|
|
|
public function __call( $name, array $param ) |
|
57
|
|
|
{ |
|
58
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Adds and returns a new customer item object |
|
64
|
|
|
* |
|
65
|
|
|
* @param array $values Values added to the newly created customer item like "customer.birthday" |
|
66
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item |
|
67
|
|
|
* @since 2017.04 |
|
68
|
|
|
*/ |
|
69
|
|
|
public function addItem( array $values ) |
|
70
|
|
|
{ |
|
71
|
|
|
return $this->controller->addItem( $values ); |
|
|
|
|
|
|
72
|
|
|
} |
|
73
|
|
|
|
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Creates a new customer item object pre-filled with the given values but not yet stored |
|
77
|
|
|
* |
|
78
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item |
|
79
|
|
|
* @since 2017.04 |
|
80
|
|
|
*/ |
|
81
|
|
|
public function createItem( array $values = [] ) |
|
82
|
|
|
{ |
|
83
|
|
|
return $this->controller->createItem( $values ); |
|
|
|
|
|
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
|
|
87
|
|
|
/** |
|
88
|
|
|
* Deletes a customer item that belongs to the current authenticated user |
|
89
|
|
|
* |
|
90
|
|
|
* @param string $id Unique customer ID |
|
91
|
|
|
* @since 2017.04 |
|
92
|
|
|
*/ |
|
93
|
|
|
public function deleteItem( $id ) |
|
94
|
|
|
{ |
|
95
|
|
|
return $this->controller->deleteItem( $id ); |
|
|
|
|
|
|
96
|
|
|
} |
|
97
|
|
|
|
|
98
|
|
|
|
|
99
|
|
|
/** |
|
100
|
|
|
* Updates the customer item identified by its ID |
|
101
|
|
|
* |
|
102
|
|
|
* @param string $id Unique customer ID |
|
103
|
|
|
* @param array $values Values added to the customer item like "customer.birthday" or "customer.city" |
|
104
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item |
|
105
|
|
|
* @since 2017.04 |
|
106
|
|
|
*/ |
|
107
|
|
|
public function editItem( $id, array $values ) |
|
108
|
|
|
{ |
|
109
|
|
|
return $this->controller->editItem( $id, $values ); |
|
|
|
|
|
|
110
|
|
|
} |
|
111
|
|
|
|
|
112
|
|
|
|
|
113
|
|
|
/** |
|
114
|
|
|
* Returns the customer item for the given customer ID |
|
115
|
|
|
* |
|
116
|
|
|
* @param string|null $id Unique customer ID or null for current customer item |
|
117
|
|
|
* @param string[] $domains Domain names of items that are associated with the customers and that should be fetched too |
|
118
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
|
119
|
|
|
* @since 2017.04 |
|
120
|
|
|
*/ |
|
121
|
|
|
public function getItem( $id = null, array $domains = [] ) |
|
122
|
|
|
{ |
|
123
|
|
|
return $this->controller->getItem( $id, $domains ); |
|
|
|
|
|
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Returns the customer item for the given customer code (usually e-mail address) |
|
129
|
|
|
* |
|
130
|
|
|
* This method doesn't check if the customer item belongs to the logged in user! |
|
131
|
|
|
* |
|
132
|
|
|
* @param string $code Unique customer code |
|
133
|
|
|
* @param string[] $domains Domain names of items that are associated with the customers and that should be fetched too |
|
134
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
|
135
|
|
|
* @since 2017.04 |
|
136
|
|
|
*/ |
|
137
|
|
|
public function findItem( $code, array $domains = [] ) |
|
138
|
|
|
{ |
|
139
|
|
|
return $this->controller->findItem( $code, $domains ); |
|
|
|
|
|
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Stores a modified customer item |
|
145
|
|
|
* |
|
146
|
|
|
* @param \Aimeos\MShop\Customer\Item\Iface Customer item |
|
147
|
|
|
* @since 2017.04 |
|
148
|
|
|
*/ |
|
149
|
|
|
public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
150
|
|
|
{ |
|
151
|
|
|
return $this->controller->saveItem( $item ); |
|
|
|
|
|
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
|
|
155
|
|
|
/** |
|
156
|
|
|
* Creates and returns a new address item object |
|
157
|
|
|
* |
|
158
|
|
|
* @param array $values Values added to the newly created customer item like "customer.birthday" |
|
159
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer address item |
|
160
|
|
|
* @since 2017.04 |
|
161
|
|
|
*/ |
|
162
|
|
|
public function addAddressItem( array $values ) |
|
163
|
|
|
{ |
|
164
|
|
|
return $this->controller->addAddressItem( $values ); |
|
|
|
|
|
|
165
|
|
|
} |
|
166
|
|
|
|
|
167
|
|
|
|
|
168
|
|
|
/** |
|
169
|
|
|
* Creates a new customer address item object pre-filled with the given values but not yet stored |
|
170
|
|
|
* |
|
171
|
|
|
* @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
|
172
|
|
|
* @since 2017.04 |
|
173
|
|
|
*/ |
|
174
|
|
|
public function createAddressItem( array $values = [] ) |
|
175
|
|
|
{ |
|
176
|
|
|
return $this->controller->createAddressItem( $values ); |
|
|
|
|
|
|
177
|
|
|
} |
|
178
|
|
|
|
|
179
|
|
|
|
|
180
|
|
|
/** |
|
181
|
|
|
* Deletes a address item that belongs to the current authenticated user |
|
182
|
|
|
* |
|
183
|
|
|
* @param string $id Unique customer address ID |
|
184
|
|
|
* @since 2017.04 |
|
185
|
|
|
*/ |
|
186
|
|
|
public function deleteAddressItem( $id ) |
|
187
|
|
|
{ |
|
188
|
|
|
$this->controller->deleteAddressItem( $id ); |
|
|
|
|
|
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
|
|
192
|
|
|
/** |
|
193
|
|
|
* Saves a modified address item object |
|
194
|
|
|
* |
|
195
|
|
|
* @param string $id Unique customer address ID |
|
196
|
|
|
* @param array $values Values added to the address item like "customer.address.city" |
|
197
|
|
|
* @return \Aimeos\MShop\Customer\Item\Iface Customer address item |
|
198
|
|
|
* @since 2017.04 |
|
199
|
|
|
*/ |
|
200
|
|
|
public function editAddressItem( $id, array $values ) |
|
201
|
|
|
{ |
|
202
|
|
|
return $this->controller->editAddressItem( $id, $values ); |
|
|
|
|
|
|
203
|
|
|
} |
|
204
|
|
|
|
|
205
|
|
|
|
|
206
|
|
|
/** |
|
207
|
|
|
* Returns the address item for the given ID |
|
208
|
|
|
* |
|
209
|
|
|
* @param string $id Unique customer address ID |
|
210
|
|
|
* @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
|
211
|
|
|
* @since 2017.04 |
|
212
|
|
|
*/ |
|
213
|
|
|
public function getAddressItem( $id ) |
|
214
|
|
|
{ |
|
215
|
|
|
return $this->controller->getAddressItem( $id ); |
|
|
|
|
|
|
216
|
|
|
} |
|
217
|
|
|
|
|
218
|
|
|
|
|
219
|
|
|
/** |
|
220
|
|
|
* Stores a modified customer address item |
|
221
|
|
|
* |
|
222
|
|
|
* @param \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
|
223
|
|
|
* @since 2017.04 |
|
224
|
|
|
*/ |
|
225
|
|
|
public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
226
|
|
|
{ |
|
227
|
|
|
$this->controller->saveAddressItem( $item ); |
|
|
|
|
|
|
228
|
|
|
} |
|
229
|
|
|
|
|
230
|
|
|
|
|
231
|
|
|
/** |
|
232
|
|
|
* Returns the frontend controller |
|
233
|
|
|
* |
|
234
|
|
|
* @return \Aimeos\Controller\Frontend\Customer\Iface Frontend controller object |
|
235
|
|
|
* @since 2017.04 |
|
236
|
|
|
*/ |
|
237
|
|
|
protected function getController() |
|
238
|
|
|
{ |
|
239
|
|
|
return $this->controller; |
|
240
|
|
|
} |
|
241
|
|
|
} |
|
242
|
|
|
|