1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2015-2020 |
6
|
|
|
* @package MShop |
7
|
|
|
* @subpackage Customer |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\MShop\Customer\Manager\Address; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Fos user bundle implementation of the customer address class. |
16
|
|
|
* |
17
|
|
|
* @package MShop |
18
|
|
|
* @subpackage Customer |
19
|
|
|
*/ |
20
|
|
|
class FosUser |
21
|
|
|
extends \Aimeos\MShop\Customer\Manager\Address\Standard |
22
|
|
|
{ |
23
|
|
|
private $searchConfig = array( |
24
|
|
|
'customer.address.id' => array( |
25
|
|
|
'label' => 'Customer address ID', |
26
|
|
|
'code' => 'customer.address.id', |
27
|
|
|
'internalcode' => 'fosad."id"', |
28
|
|
|
'internaldeps' => array( 'LEFT JOIN "fos_user_address" AS fosad ON ( fos."id" = fosad."parentid" )' ), |
29
|
|
|
'type' => 'integer', |
30
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
31
|
|
|
'public' => false, |
32
|
|
|
), |
33
|
|
|
'customer.address.siteid' => array( |
34
|
|
|
'code' => 'customer.address.siteid', |
35
|
|
|
'internalcode' => 'fosad."siteid"', |
36
|
|
|
'label' => 'Customer address site ID', |
37
|
|
|
'type' => 'string', |
38
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
39
|
|
|
'public' => false, |
40
|
|
|
), |
41
|
|
|
'customer.address.refid' => array( |
42
|
|
|
'label' => 'Customer address parent ID', |
43
|
|
|
'code' => 'customer.address.parentid', |
44
|
|
|
'internalcode' => 'fosad."parentid"', |
45
|
|
|
'type' => 'integer', |
46
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
47
|
|
|
'public' => false, |
48
|
|
|
), |
49
|
|
|
'customer.address.company' => array( |
50
|
|
|
'label' => 'Customer address company', |
51
|
|
|
'code' => 'customer.address.company', |
52
|
|
|
'internalcode' => 'fosad."company"', |
53
|
|
|
'type' => 'string', |
54
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
55
|
|
|
), |
56
|
|
|
'customer.address.vatid' => array( |
57
|
|
|
'label' => 'Customer address VAT ID', |
58
|
|
|
'code' => 'customer.address.vatid', |
59
|
|
|
'internalcode' => 'fosad."vatid"', |
60
|
|
|
'type' => 'string', |
61
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
62
|
|
|
), |
63
|
|
|
'customer.address.salutation' => array( |
64
|
|
|
'label' => 'Customer address salutation', |
65
|
|
|
'code' => 'customer.address.salutation', |
66
|
|
|
'internalcode' => 'fosad."salutation"', |
67
|
|
|
'type' => 'integer', |
68
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
69
|
|
|
), |
70
|
|
|
'customer.address.title' => array( |
71
|
|
|
'label' => 'Customer address title', |
72
|
|
|
'code' => 'customer.address.title', |
73
|
|
|
'internalcode' => 'fosad."title"', |
74
|
|
|
'type' => 'string', |
75
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
76
|
|
|
), |
77
|
|
|
'customer.address.firstname' => array( |
78
|
|
|
'label' => 'Customer address firstname', |
79
|
|
|
'code' => 'customer.address.firstname', |
80
|
|
|
'internalcode' => 'fosad."firstname"', |
81
|
|
|
'type' => 'string', |
82
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
83
|
|
|
), |
84
|
|
|
'customer.address.lastname' => array( |
85
|
|
|
'label' => 'Customer address lastname', |
86
|
|
|
'code' => 'customer.address.lastname', |
87
|
|
|
'internalcode' => 'fosad."lastname"', |
88
|
|
|
'type' => 'string', |
89
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
90
|
|
|
), |
91
|
|
|
'customer.address.address1' => array( |
92
|
|
|
'label' => 'Customer address address part one', |
93
|
|
|
'code' => 'customer.address.address1', |
94
|
|
|
'internalcode' => 'fosad."address1"', |
95
|
|
|
'type' => 'string', |
96
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
97
|
|
|
), |
98
|
|
|
'customer.address.address2' => array( |
99
|
|
|
'label' => 'Customer address address part two', |
100
|
|
|
'code' => 'customer.address.address2', |
101
|
|
|
'internalcode' => 'fosad."address2"', |
102
|
|
|
'type' => 'string', |
103
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
104
|
|
|
), |
105
|
|
|
'customer.address.address3' => array( |
106
|
|
|
'label' => 'Customer address address part three', |
107
|
|
|
'code' => 'customer.address.address3', |
108
|
|
|
'internalcode' => 'fosad."address3"', |
109
|
|
|
'type' => 'string', |
110
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
111
|
|
|
), |
112
|
|
|
'customer.address.postal' => array( |
113
|
|
|
'label' => 'Customer address postal', |
114
|
|
|
'code' => 'customer.address.postal', |
115
|
|
|
'internalcode' => 'fosad."postal"', |
116
|
|
|
'type' => 'string', |
117
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
118
|
|
|
), |
119
|
|
|
'customer.address.city' => array( |
120
|
|
|
'label' => 'Customer address city', |
121
|
|
|
'code' => 'customer.address.city', |
122
|
|
|
'internalcode' => 'fosad."city"', |
123
|
|
|
'type' => 'string', |
124
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
125
|
|
|
), |
126
|
|
|
'customer.address.state' => array( |
127
|
|
|
'label' => 'Customer address state', |
128
|
|
|
'code' => 'customer.address.state', |
129
|
|
|
'internalcode' => 'fosad."state"', |
130
|
|
|
'type' => 'string', |
131
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
132
|
|
|
), |
133
|
|
|
'customer.address.languageid' => array( |
134
|
|
|
'label' => 'Customer address language', |
135
|
|
|
'code' => 'customer.address.languageid', |
136
|
|
|
'internalcode' => 'fosad."langid"', |
137
|
|
|
'type' => 'string', |
138
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
139
|
|
|
), |
140
|
|
|
'customer.address.countryid' => array( |
141
|
|
|
'label' => 'Customer address country', |
142
|
|
|
'code' => 'customer.address.countryid', |
143
|
|
|
'internalcode' => 'fosad."countryid"', |
144
|
|
|
'type' => 'string', |
145
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
146
|
|
|
), |
147
|
|
|
'customer.address.telephone' => array( |
148
|
|
|
'label' => 'Customer address telephone', |
149
|
|
|
'code' => 'customer.address.telephone', |
150
|
|
|
'internalcode' => 'fosad."telephone"', |
151
|
|
|
'type' => 'string', |
152
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
153
|
|
|
), |
154
|
|
|
'customer.address.email' => array( |
155
|
|
|
'label' => 'Customer address email', |
156
|
|
|
'code' => 'customer.address.email', |
157
|
|
|
'internalcode' => 'fosad."email"', |
158
|
|
|
'type' => 'string', |
159
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
160
|
|
|
), |
161
|
|
|
'customer.address.telefax' => array( |
162
|
|
|
'label' => 'Customer address telefax', |
163
|
|
|
'code' => 'customer.address.telefax', |
164
|
|
|
'internalcode' => 'fosad."telefax"', |
165
|
|
|
'type' => 'string', |
166
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
167
|
|
|
), |
168
|
|
|
'customer.address.website' => array( |
169
|
|
|
'label' => 'Customer address website', |
170
|
|
|
'code' => 'customer.address.website', |
171
|
|
|
'internalcode' => 'fosad."website"', |
172
|
|
|
'type' => 'string', |
173
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
174
|
|
|
), |
175
|
|
|
'customer.address.longitude' => array( |
176
|
|
|
'label' => 'Customer address longitude', |
177
|
|
|
'code' => 'customer.address.longitude', |
178
|
|
|
'internalcode' => 'fosad."longitude"', |
179
|
|
|
'type' => 'float', |
180
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT, |
181
|
|
|
), |
182
|
|
|
'customer.address.latitude' => array( |
183
|
|
|
'label' => 'Customer address latitude', |
184
|
|
|
'code' => 'customer.address.latitude', |
185
|
|
|
'internalcode' => 'fosad."latitude"', |
186
|
|
|
'type' => 'float', |
187
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_FLOAT, |
188
|
|
|
), |
189
|
|
|
'customer.address.position' => array( |
190
|
|
|
'label' => 'Customer address position', |
191
|
|
|
'code' => 'customer.address.position', |
192
|
|
|
'internalcode' => 'fosad."pos"', |
193
|
|
|
'type' => 'integer', |
194
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT, |
195
|
|
|
), |
196
|
|
|
'customer.address.birthday' => array( |
197
|
|
|
'label' => 'Customer address birthday', |
198
|
|
|
'code' => 'customer.address.birthday', |
199
|
|
|
'internalcode' => 'fosad."birthday"', |
200
|
|
|
'type' => 'date', |
201
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
202
|
|
|
), |
203
|
|
|
'customer.address.ctime' => array( |
204
|
|
|
'label' => 'Customer address create date/time', |
205
|
|
|
'code' => 'customer.address.ctime', |
206
|
|
|
'internalcode' => 'fosad."ctime"', |
207
|
|
|
'type' => 'datetime', |
208
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
209
|
|
|
), |
210
|
|
|
'customer.address.mtime' => array( |
211
|
|
|
'label' => 'Customer address modification date/time', |
212
|
|
|
'code' => 'customer.address.mtime', |
213
|
|
|
'internalcode' => 'fosad."mtime"', |
214
|
|
|
'type' => 'datetime', |
215
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
216
|
|
|
), |
217
|
|
|
'customer.address.editor' => array( |
218
|
|
|
'label' => 'Customer address editor', |
219
|
|
|
'code' => 'customer.address.editor', |
220
|
|
|
'internalcode' => 'fosad."editor"', |
221
|
|
|
'type' => 'string', |
222
|
|
|
'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR, |
223
|
|
|
), |
224
|
|
|
); |
225
|
|
|
|
226
|
|
|
|
227
|
|
|
/** |
228
|
|
|
* Removes old entries from the storage. |
229
|
|
|
* |
230
|
|
|
* @param string[] $siteids List of IDs for sites whose entries should be deleted |
231
|
|
|
* @return \Aimeos\MShop\Common\Manager\Iface Same object for fluent interface |
232
|
|
|
*/ |
233
|
|
|
public function clear( array $siteids ) : \Aimeos\MShop\Common\Manager\Iface |
234
|
|
|
{ |
235
|
|
|
$path = 'mshop/customer/manager/address/submanagers'; |
236
|
|
|
foreach( $this->getContext()->getConfig()->get( $path, [] ) as $domain ) { |
237
|
|
|
$this->getObject()->getSubManager( $domain )->clear( $siteids ); |
238
|
|
|
} |
239
|
|
|
|
240
|
|
|
return $this->clearBase( $siteids, 'mshop/customer/manager/lists/fosuser/delete' ); |
241
|
|
|
} |
242
|
|
|
|
243
|
|
|
|
244
|
|
|
/** |
245
|
|
|
* Returns the list attributes that can be used for searching. |
246
|
|
|
* |
247
|
|
|
* @param bool $withsub Return also attributes of sub-managers if true |
248
|
|
|
* @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface |
249
|
|
|
*/ |
250
|
|
|
public function getSearchAttributes( bool $withsub = true ) : array |
251
|
|
|
{ |
252
|
|
|
$path = 'mshop/customer/manager/address/submanagers'; |
253
|
|
|
|
254
|
|
|
return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub ); |
255
|
|
|
} |
256
|
|
|
|
257
|
|
|
|
258
|
|
|
/** |
259
|
|
|
* Returns a new manager for customer extensions |
260
|
|
|
* |
261
|
|
|
* @param string $manager Name of the sub manager type in lower case |
262
|
|
|
* @param string|null $name Name of the implementation, will be from configuration (or Default) if null |
263
|
|
|
* @return mixed Manager for different extensions, e.g stock, tags, locations, etc. |
264
|
|
|
*/ |
265
|
|
|
public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface |
266
|
|
|
{ |
267
|
|
|
return $this->getSubManagerBase( 'customer', 'address/' . $manager, ( $name === null ? 'FosUser' : $name ) ); |
268
|
|
|
} |
269
|
|
|
|
270
|
|
|
|
271
|
|
|
/** |
272
|
|
|
* Returns the config path for retrieving the configuration values. |
273
|
|
|
* |
274
|
|
|
* @return string Configuration path (mshop/customer/manager/address/fosuser/) |
275
|
|
|
*/ |
276
|
|
|
protected function getConfigPath() : string |
277
|
|
|
{ |
278
|
|
|
return 'mshop/customer/manager/address/fosuser/'; |
279
|
|
|
} |
280
|
|
|
|
281
|
|
|
|
282
|
|
|
/** |
283
|
|
|
* Returns the search configuration for searching items. |
284
|
|
|
* |
285
|
|
|
* @return array Associative list of search keys and search definitions |
286
|
|
|
*/ |
287
|
|
|
protected function getSearchConfig() : array |
288
|
|
|
{ |
289
|
|
|
return $this->searchConfig; |
290
|
|
|
} |
291
|
|
|
} |
292
|
|
|
|