• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

aimeos / aimeos-core / be5b2722-8208-42fc-9362-4640a66e38cf

13 Sep 2024 08:05AM UTC coverage: 92.186% (-0.02%) from 92.207%
be5b2722-8208-42fc-9362-4640a66e38cf

push

circleci

aimeos
Simplified customer manager

227 of 229 new or added lines in 5 files covered. (99.13%)

15 existing lines in 2 files now uncovered.

9804 of 10635 relevant lines covered (92.19%)

72.46 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.26
/src/MShop/Customer/Manager/Standard.php
1
<?php
2

3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2024
6
 * @package MShop
7
 * @subpackage Customer
8
 */
9

10

11
namespace Aimeos\MShop\Customer\Manager;
12

13

14
/**
15
 * Default implementation of the customer class.
16
 *
17
 * @package MShop
18
 * @subpackage Customer
19
 */
20
class Standard
21
        extends \Aimeos\MShop\Customer\Manager\Base
22
        implements \Aimeos\MShop\Customer\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
23
{
24
        /**
25
         * Removes old entries from the storage.
26
         *
27
         * @param iterable $siteids List of IDs for sites whose entries should be deleted
28
         * @return \Aimeos\MShop\Customer\Manager\Iface Manager object for chaining method calls
29
         */
30
        public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface
31
        {
32
                foreach( $this->context()->config()->get( 'mshop/customer/manager/submanagers', [] ) as $domain ) {
4✔
33
                        $this->object()->getSubManager( $domain )->clear( $siteids );
4✔
34
                }
35

36
                return $this->clearBase( $siteids, 'mshop/customer/manager/clear' );
4✔
37
        }
38

39

40
        /**
41
         * Creates a new empty item instance
42
         *
43
         * @param array $values Values the item should be initialized with
44
         * @return \Aimeos\MShop\Customer\Item\Iface New customer item object
45
         */
46
        public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
47
        {
48
                $values['customer.siteid'] = $values['customer.siteid'] ?? $this->context()->locale()->getSiteId();
32✔
49

50
                $address = new \Aimeos\MShop\Common\Item\Address\Standard( 'customer.', $values );
32✔
51
                return new \Aimeos\MShop\Customer\Item\Standard( $address, 'customer.', $values, $this->context()->password() );
32✔
52
        }
53

54

55
        /**
56
         * Returns the attributes that can be used for searching.
57
         *
58
         * @param bool $withsub Return also attributes of sub-managers if true
59
         * @return \Aimeos\Base\Criteria\Attribute\Iface List of search attribute items
60
         */
61
        public function getSearchAttributes( bool $withsub = true ) : array
62
        {
63
                $level = \Aimeos\MShop\Locale\Manager\Base::SITE_ALL;
34✔
64
                $level = $this->context()->config()->get( 'mshop/customer/manager/sitemode', $level );
34✔
65

66
                return array_replace( parent::getSearchAttributes( $withsub ), $this->createAttributes( [
34✔
67
                        'customer.id' => [
34✔
68
                                'label' => 'ID',
34✔
69
                                'internalcode' => 'id',
34✔
70
                                'type' => 'int',
34✔
71
                                'public' => false,
34✔
72
                        ],
34✔
73
                        'customer.siteid' => [
34✔
74
                                'label' => 'Customer site ID',
34✔
75
                                'internalcode' => 'siteid',
34✔
76
                                'public' => false,
34✔
77
                        ],
34✔
78
                        'customer.code' => [
34✔
79
                                'label' => 'Username',
34✔
80
                                'internalcode' => 'code',
34✔
81
                        ],
34✔
82
                        'customer.label' => [
34✔
83
                                'label' => 'Label',
34✔
84
                                'internalcode' => 'label',
34✔
85
                        ],
34✔
86
                        'customer.salutation' => [
34✔
87
                                'label' => 'Salutation',
34✔
88
                                'internalcode' => 'salutation',
34✔
89
                        ],
34✔
90
                        'customer.company' => [
34✔
91
                                'label' => 'Company',
34✔
92
                                'internalcode' => 'company',
34✔
93
                        ],
34✔
94
                        'customer.vatid' => [
34✔
95
                                'label' => 'Vat ID',
34✔
96
                                'internalcode' => 'vatid',
34✔
97
                        ],
34✔
98
                        'customer.title' => [
34✔
99
                                'label' => 'Title',
34✔
100
                                'internalcode' => 'title',
34✔
101
                        ],
34✔
102
                        'customer.firstname' => [
34✔
103
                                'label' => 'Firstname',
34✔
104
                                'internalcode' => 'firstname',
34✔
105
                        ],
34✔
106
                        'customer.lastname' => [
34✔
107
                                'label' => 'Lastname',
34✔
108
                                'internalcode' => 'lastname',
34✔
109
                        ],
34✔
110
                        'customer.address1' => [
34✔
111
                                'label' => 'Address part one',
34✔
112
                                'internalcode' => 'address1',
34✔
113
                        ],
34✔
114
                        'customer.address2' => [
34✔
115
                                'label' => 'Address part two',
34✔
116
                                'internalcode' => 'address2',
34✔
117
                        ],
34✔
118
                        'customer.address3' => [
34✔
119
                                'label' => 'Address part three',
34✔
120
                                'internalcode' => 'address3',
34✔
121
                        ],
34✔
122
                        'customer.postal' => [
34✔
123
                                'label' => 'Postal',
34✔
124
                                'internalcode' => 'postal',
34✔
125
                        ],
34✔
126
                        'customer.city' => [
34✔
127
                                'label' => 'City',
34✔
128
                                'internalcode' => 'city',
34✔
129
                        ],
34✔
130
                        'customer.state' => [
34✔
131
                                'label' => 'State',
34✔
132
                                'internalcode' => 'state',
34✔
133
                        ],
34✔
134
                        'customer.languageid' => [
34✔
135
                                'label' => 'Language',
34✔
136
                                'internalcode' => 'langid',
34✔
137
                        ],
34✔
138
                        'customer.countryid' => [
34✔
139
                                'label' => 'Country',
34✔
140
                                'internalcode' => 'countryid',
34✔
141
                        ],
34✔
142
                        'customer.telephone' => [
34✔
143
                                'label' => 'Telephone',
34✔
144
                                'internalcode' => 'telephone',
34✔
145
                        ],
34✔
146
                        'customer.telefax' => [
34✔
147
                                'label' => 'Facsimile',
34✔
148
                                'internalcode' => 'telefax',
34✔
149
                        ],
34✔
150
                        'customer.mobile' => [
34✔
151
                                'label' => 'Mobile number',
34✔
152
                                'internalcode' => 'mobile',
34✔
153
                        ],
34✔
154
                        'customer.email' => [
34✔
155
                                'label' => 'E-mail',
34✔
156
                                'internalcode' => 'email',
34✔
157
                        ],
34✔
158
                        'customer.website' => [
34✔
159
                                'label' => 'Web site',
34✔
160
                                'internalcode' => 'website',
34✔
161
                        ],
34✔
162
                        'customer.longitude' => [
34✔
163
                                'label' => 'Longitude',
34✔
164
                                'internalcode' => 'longitude',
34✔
165
                                'public' => false,
34✔
166
                        ],
34✔
167
                        'customer.latitude' => [
34✔
168
                                'label' => 'Latitude',
34✔
169
                                'internalcode' => 'latitude',
34✔
170
                                'public' => false,
34✔
171
                        ],
34✔
172
                        'customer.birthday' => [
34✔
173
                                'label' => 'Birthday',
34✔
174
                                'internalcode' => 'birthday',
34✔
175
                        ],
34✔
176
                        'customer.status' => [
34✔
177
                                'label' => 'Status',
34✔
178
                                'internalcode' => 'status',
34✔
179
                                'type' => 'int',
34✔
180
                        ],
34✔
181
                        'customer.dateverified' => [
34✔
182
                                'label' => 'Verification date',
34✔
183
                                'internalcode' => 'vdate',
34✔
184
                                'type' => 'date',
34✔
185
                                'public' => false,
34✔
186
                        ],
34✔
187
                        'customer.password' => [
34✔
188
                                'label' => 'Password',
34✔
189
                                'internalcode' => 'password',
34✔
190
                                'public' => false,
34✔
191
                        ],
34✔
192
                        'customer.ctime' => [
34✔
193
                                'label' => 'Create date/time',
34✔
194
                                'internalcode' => 'ctime',
34✔
195
                                'type' => 'datetime',
34✔
196
                                'public' => false,
34✔
197
                        ],
34✔
198
                        'customer.mtime' => [
34✔
199
                                'label' => 'Modify date/time',
34✔
200
                                'internalcode' => 'mtime',
34✔
201
                                'type' => 'datetime',
34✔
202
                                'public' => false,
34✔
203
                        ],
34✔
204
                        'customer.editor' => [
34✔
205
                                'label' => 'Editor',
34✔
206
                                'internalcode' => 'editor',
34✔
207
                                'public' => false,
34✔
208
                        ],
34✔
209
                        'customer:has' => [
34✔
210
                                'code' => 'customer:has()',
34✔
211
                                'internalcode' => ':site AND :key AND mcusli."id"',
34✔
212
                                'internaldeps' => ['LEFT JOIN "mshop_customer_list" AS mcusli ON ( mcusli."parentid" = mcus."id" )'],
34✔
213
                                'label' => 'Customer has list item, parameter(<domain>[,<list type>[,<reference ID>)]]',
34✔
214
                                'type' => 'null',
34✔
215
                                'public' => false,
34✔
216
                                'function' => function( &$source, array $params ) use ( $level ) {
34✔
217
                                        $keys = [];
1✔
218

219
                                        foreach( (array) ( $params[1] ?? '' ) as $type ) {
1✔
220
                                                foreach( (array) ( $params[2] ?? '' ) as $id ) {
1✔
221
                                                        $keys[] = $params[0] . '|' . ( $type ? $type . '|' : '' ) . $id;
1✔
222
                                                }
223
                                        }
224

225
                                        $sitestr = $this->siteString( 'mcusli."siteid"', $level );
1✔
226
                                        $keystr = $this->toExpression( 'mcusli."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' );
1✔
227
                                        $source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );
1✔
228

229
                                        return $params;
1✔
230
                                }
34✔
231
                        ],
34✔
232
                        'customer:prop' => [
34✔
233
                                'code' => 'customer:prop()',
34✔
234
                                'internalcode' => ':site AND :key AND mcuspr."id"',
34✔
235
                                'internaldeps' => ['LEFT JOIN "mshop_customer_property" AS mcuspr ON ( mcuspr."parentid" = mcus."id" )'],
34✔
236
                                'label' => 'Customer has property item, parameter(<property type>[,<language code>[,<property value>]])',
34✔
237
                                'type' => 'null',
34✔
238
                                'public' => false,
34✔
239
                                'function' => function( &$source, array $params ) use ( $level ) {
34✔
240
                                        $keys = [];
1✔
241
                                        $langs = array_key_exists( 1, $params ) ? ( $params[1] ?? 'null' ) : '';
1✔
242

243
                                        foreach( (array) $langs as $lang ) {
1✔
244
                                                foreach( (array) ( $params[2] ?? '' ) as $val ) {
1✔
245
                                                        $keys[] = substr( $params[0] . '|' . ( $lang === null ? 'null|' : ( $lang ? $lang . '|' : '' ) ) . $val, 0, 255 );
1✔
246
                                                }
247
                                        }
248

249
                                        $sitestr = $this->siteString( 'mcuspr."siteid"', $level );
1✔
250
                                        $keystr = $this->toExpression( 'mcuspr."key"', $keys, ( $params[2] ?? null ) ? '==' : '=~' );
1✔
251
                                        $source = str_replace( [':site', ':key'], [$sitestr, $keystr], $source );
1✔
252

253
                                        return $params;
1✔
254
                                }
34✔
255
                        ],
34✔
256
                ] ) );
34✔
257
        }
258

259

260
        /**
261
         * Removes multiple items.
262
         *
263
         * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $items List of item objects or IDs of the items
264
         * @return \Aimeos\MShop\Customer\Manager\Iface Manager object for chaining method calls
265
         */
266
        public function delete( $items ) : \Aimeos\MShop\Common\Manager\Iface
267
        {
268
                return $this->deleteItemsBase( $items, 'mshop/customer/manager/delete' )->deleteRefItems( $items );
3✔
269
        }
270

271

272
        /**
273
         * Saves a customer item object.
274
         *
275
         * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item object
276
         * @param bool $fetch True if the new ID should be returned in the item
277
         * @return \Aimeos\MShop\Customer\Item\Iface $item Updated item including the generated ID
278
         */
279
        protected function saveItem( \Aimeos\MShop\Customer\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Customer\Item\Iface
280
        {
281
                $item = $this->addGroups( $item );
3✔
282

283
                if( !$item->isModified() ) {
3✔
NEW
284
                        return $this->saveDeps( $item, $fetch );
×
285
                }
286

287
                $context = $this->context();
3✔
288
                $conn = $context->db( $this->getResourceName() );
3✔
289

290
                $id = $item->getId();
3✔
291
                $billingAddress = $item->getPaymentAddress();
3✔
292
                $columns = $this->object()->getSaveAttributes();
3✔
293

294
                if( $id === null )
3✔
295
                {
296
                        /** mshop/customer/manager/insert/mysql
297
                         * Inserts a new customer record into the database table
298
                         *
299
                         * @see mshop/customer/manager/insert/ansi
300
                         */
301

302
                        /** mshop/customer/manager/insert/ansi
303
                         * Inserts a new customer record into the database table
304
                         *
305
                         * Items with no ID yet (i.e. the ID is NULL) will be created in
306
                         * the database and the newly created ID retrieved afterwards
307
                         * using the "newid" SQL statement.
308
                         *
309
                         * The SQL statement must be a string suitable for being used as
310
                         * prepared statement. It must include question marks for binding
311
                         * the values from the customer item to the statement before they are
312
                         * sent to the database server. The number of question marks must
313
                         * be the same as the number of columns listed in the INSERT
314
                         * statement. The order of the columns must correspond to the
315
                         * order in the save() method, so the correct values are
316
                         * bound to the columns.
317
                         *
318
                         * The SQL statement should conform to the ANSI standard to be
319
                         * compatible with most relational database systems. This also
320
                         * includes using double quotes for table and column names.
321
                         *
322
                         * @param string SQL statement for inserting records
323
                         * @since 2015.10
324
                         * @see mshop/customer/manager/update/ansi
325
                         * @see mshop/customer/manager/newid/ansi
326
                         * @see mshop/customer/manager/delete/ansi
327
                         * @see mshop/customer/manager/search/ansi
328
                         * @see mshop/customer/manager/count/ansi
329
                         */
330
                        $path = 'mshop/customer/manager/insert';
3✔
331
                        $sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ) );
3✔
332
                }
333
                else
334
                {
335
                        /** mshop/customer/manager/update/mysql
336
                         * Updates an existing customer record in the database
337
                         *
338
                         * @see mshop/customer/manager/update/ansi
339
                         */
340

341
                        /** mshop/customer/manager/update/ansi
342
                         * Updates an existing customer record in the database
343
                         *
344
                         * Items which already have an ID (i.e. the ID is not NULL) will
345
                         * be updated in the database.
346
                         *
347
                         * The SQL statement must be a string suitable for being used as
348
                         * prepared statement. It must include question marks for binding
349
                         * the values from the customer item to the statement before they are
350
                         * sent to the database server. The order of the columns must
351
                         * correspond to the order in the save() method, so the
352
                         * correct values are bound to the columns.
353
                         *
354
                         * The SQL statement should conform to the ANSI standard to be
355
                         * compatible with most relational database systems. This also
356
                         * includes using double quotes for table and column names.
357
                         *
358
                         * @param string SQL statement for updating records
359
                         * @since 2015.10
360
                         * @see mshop/customer/manager/insert/ansi
361
                         * @see mshop/customer/manager/newid/ansi
362
                         * @see mshop/customer/manager/delete/ansi
363
                         * @see mshop/customer/manager/search/ansi
364
                         * @see mshop/customer/manager/count/ansi
365
                         */
366
                        $path = 'mshop/customer/manager/update';
1✔
367
                        $sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ), false );
1✔
368
                }
369

370
                $idx = 1;
3✔
371
                $stmt = $this->getCachedStatement( $conn, $path, $sql );
3✔
372

373
                foreach( $columns as $name => $entry ) {
3✔
374
                        $stmt->bind( $idx++, $item->get( $name ), \Aimeos\Base\Criteria\SQL::type( $entry->getType() ) );
×
375
                }
376

377
                $stmt->bind( $idx++, $item->getLabel() );
3✔
378
                $stmt->bind( $idx++, $item->getCode() );
3✔
379
                $stmt->bind( $idx++, $billingAddress->getCompany() );
3✔
380
                $stmt->bind( $idx++, $billingAddress->getVatID() );
3✔
381
                $stmt->bind( $idx++, $billingAddress->getSalutation() );
3✔
382
                $stmt->bind( $idx++, $billingAddress->getTitle() );
3✔
383
                $stmt->bind( $idx++, $billingAddress->getFirstname() );
3✔
384
                $stmt->bind( $idx++, $billingAddress->getLastname() );
3✔
385
                $stmt->bind( $idx++, $billingAddress->getAddress1() );
3✔
386
                $stmt->bind( $idx++, $billingAddress->getAddress2() );
3✔
387
                $stmt->bind( $idx++, $billingAddress->getAddress3() );
3✔
388
                $stmt->bind( $idx++, $billingAddress->getPostal() );
3✔
389
                $stmt->bind( $idx++, $billingAddress->getCity() );
3✔
390
                $stmt->bind( $idx++, $billingAddress->getState() );
3✔
391
                $stmt->bind( $idx++, $billingAddress->getCountryId() );
3✔
392
                $stmt->bind( $idx++, $billingAddress->getLanguageId() );
3✔
393
                $stmt->bind( $idx++, $billingAddress->getTelephone() );
3✔
394
                $stmt->bind( $idx++, $billingAddress->getMobile() );
3✔
395
                $stmt->bind( $idx++, $billingAddress->getEmail() );
3✔
396
                $stmt->bind( $idx++, $billingAddress->getTelefax() );
3✔
397
                $stmt->bind( $idx++, $billingAddress->getWebsite() );
3✔
398
                $stmt->bind( $idx++, $billingAddress->getLongitude() );
3✔
399
                $stmt->bind( $idx++, $billingAddress->getLatitude() );
3✔
400
                $stmt->bind( $idx++, $billingAddress->getBirthday() );
3✔
401
                $stmt->bind( $idx++, $item->getStatus(), \Aimeos\Base\DB\Statement\Base::PARAM_INT );
3✔
402
                $stmt->bind( $idx++, $item->getDateVerified() );
3✔
403
                $stmt->bind( $idx++, $item->getPassword() );
3✔
404
                $stmt->bind( $idx++, $context->datetime() ); // Modification time
3✔
405
                $stmt->bind( $idx++, $context->editor() );
3✔
406

407
                if( $id !== null ) {
3✔
408
                        $stmt->bind( $idx++, $context->locale()->getSiteId() . '%' );
1✔
409
                        $stmt->bind( $idx++, $this->getUser()?->getSiteId() );
1✔
410
                        $stmt->bind( $idx, $id, \Aimeos\Base\DB\Statement\Base::PARAM_INT );
1✔
411
                        $billingAddress->setId( $id ); // enforce ID to be present
1✔
412
                } else {
413
                        $stmt->bind( $idx++, $this->siteId( $item->getSiteId(), \Aimeos\MShop\Locale\Manager\Base::SITE_SUBTREE ) );
3✔
414
                        $stmt->bind( $idx, $context->datetime() ); // Creation time
3✔
415
                }
416

417
                $stmt->execute()->finish();
3✔
418

419
                if( $id === null )
3✔
420
                {
421
                        /** mshop/customer/manager/newid/mysql
422
                         * Retrieves the ID generated by the database when inserting a new record
423
                         *
424
                         * @see mshop/customer/manager/newid/ansi
425
                         */
426

427
                        /** mshop/customer/manager/newid/ansi
428
                         * Retrieves the ID generated by the database when inserting a new record
429
                         *
430
                         * As soon as a new record is inserted into the database table,
431
                         * the database server generates a new and unique identifier for
432
                         * that record. This ID can be used for retrieving, updating and
433
                         * deleting that specific record from the table again.
434
                         *
435
                         * For MySQL:
436
                         *  SELECT LAST_INSERT_ID()
437
                         * For PostgreSQL:
438
                         *  SELECT currval('seq_mcus_id')
439
                         * For SQL Server:
440
                         *  SELECT SCOPE_IDENTITY()
441
                         * For Oracle:
442
                         *  SELECT "seq_mcus_id".CURRVAL FROM DUAL
443
                         *
444
                         * There's no way to retrive the new ID by a SQL statements that
445
                         * fits for most database servers as they implement their own
446
                         * specific way.
447
                         *
448
                         * @param string SQL statement for retrieving the last inserted record ID
449
                         * @since 2015.10
450
                         * @see mshop/customer/manager/insert/ansi
451
                         * @see mshop/customer/manager/update/ansi
452
                         * @see mshop/customer/manager/delete/ansi
453
                         * @see mshop/customer/manager/search/ansi
454
                         * @see mshop/customer/manager/count/ansi
455
                         */
456
                        $path = 'mshop/customer/manager/newid';
3✔
457
                        $id = $this->newId( $conn, $path );
3✔
458
                }
459

460
                return $this->saveDeps( $item->setId( $id ), $fetch );
3✔
461
        }
462

463

464
        /**
465
         * Fetches the rows from the database statement and returns the list of items.
466
         *
467
         * @param \Aimeos\Base\DB\Result\Iface $stmt Database statement object
468
         * @param array $ref List of domains whose items should be fetched too
469
         * @param string $prefix Prefix for the property names
470
         * @param array $attrs List of attributes that should be decoded
471
         * @return \Aimeos\Map List of items implementing \Aimeos\MShop\Common\Item\Iface
472
         */
473
        protected function fetch( \Aimeos\Base\DB\Result\Iface $results, array $ref, string $prefix = '', array $attrs = [] ) : \Aimeos\Map
474
        {
475
                $map = $items = $parentIds = $propItems = $addrItems = [];
31✔
476

477
                while( $row = $results->fetch() )
31✔
478
                {
479
                        $map[$row['customer.id']] = $row;
31✔
480
                        $parentIds[] = $row['customer.id'];
31✔
481
                }
482

483
                if( $this->hasRef( $ref, 'customer/address' ) ) {
31✔
484
                        $addrItems = $this->getAddressItems( $parentIds, 'customer' );
2✔
485
                }
486

487
                if( $this->hasRef( $ref, 'customer/property' ) )
31✔
488
                {
489
                        $name = 'customer/property';
2✔
490
                        $propTypes = isset( $ref[$name] ) && is_array( $ref[$name] ) ? $ref[$name] : null;
2✔
491

492
                        $propItems = $this->getPropertyItems( $parentIds, 'customer', $propTypes );
2✔
493
                }
494

495
                $listItems = map( $this->getListItems( $parentIds, $ref, 'customer' ) )->groupBy( 'customer.lists.parentid' );
31✔
496

497
                foreach( $map as $id => $row )
31✔
498
                {
499
                        $row['.addritems'] = $addrItems[$id] ?? [];
31✔
500
                        $row['.listitems'] = $listItems[$id] ?? [];
31✔
501
                        $row['.propitems'] = $propItems[$id] ?? [];
31✔
502

503
                        if( $item = $this->applyFilter( $this->create( $row ) ) ) {
31✔
504
                                $items[$id] = $item;
31✔
505
                        }
506
                }
507

508
                return map( $items );
31✔
509
        }
510

511

512
        /**
513
         * Returns the prefix for the item properties and search keys.
514
         *
515
         * @return string Prefix for the item properties and search keys
516
         */
517
        protected function prefix() : string
518
        {
519
                return 'customer.';
34✔
520
        }
521

522

523
        /**
524
         * Saves the dependent items of the item
525
         *
526
         * @param \Aimeos\MShop\Common\Item\Iface $item Item object
527
         * @param bool $fetch True if the new ID should be returned in the item
528
         * @return \Aimeos\MShop\Common\Item\Iface Updated item
529
         */
530
        protected function saveDeps( \Aimeos\MShop\Common\Item\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Common\Item\Iface
531
        {
532
                $item = $this->savePropertyItems( $item, 'customer', $fetch );
3✔
533
                $item = $this->saveAddressItems( $item, 'customer', $fetch );
3✔
534
                return $this->saveListItems( $item, 'customer', $fetch );
3✔
535
        }
536

537

538
        /** mshop/customer/manager/name
539
         * Class name of the used customer manager implementation
540
         *
541
         * Each default manager can be replace by an alternative imlementation.
542
         * To use this implementation, you have to set the last part of the class
543
         * name as configuration value so the manager factory knows which class it
544
         * has to instantiate.
545
         *
546
         * For example, if the name of the default class is
547
         *
548
         *  \Aimeos\MShop\Customer\Manager\Standard
549
         *
550
         * and you want to replace it with your own version named
551
         *
552
         *  \Aimeos\MShop\Customer\Manager\Mymanager
553
         *
554
         * then you have to set the this configuration option:
555
         *
556
         *  mshop/customer/manager/name = Mymanager
557
         *
558
         * The value is the last part of your own class name and it's case sensitive,
559
         * so take care that the configuration value is exactly named like the last
560
         * part of the class name.
561
         *
562
         * The allowed characters of the class name are A-Z, a-z and 0-9. No other
563
         * characters are possible! You should always start the last part of the class
564
         * name with an upper case character and continue only with lower case characters
565
         * or numbers. Avoid chamel case names like "MyManager"!
566
         *
567
         * @param string Last part of the class name
568
         * @since 2015.10
569
         */
570

571
        /** mshop/customer/manager/decorators/excludes
572
         * Excludes decorators added by the "common" option from the customer manager
573
         *
574
         * Decorators extend the functionality of a class by adding new aspects
575
         * (e.g. log what is currently done), executing the methods of the underlying
576
         * class only in certain conditions (e.g. only for logged in users) or
577
         * modify what is returned to the caller.
578
         *
579
         * This option allows you to remove a decorator added via
580
         * "mshop/common/manager/decorators/default" before they are wrapped
581
         * around the customer manager.
582
         *
583
         *  mshop/customer/manager/decorators/excludes = array( 'decorator1' )
584
         *
585
         * This would remove the decorator named "decorator1" from the list of
586
         * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
587
         * "mshop/common/manager/decorators/default" for the customer manager.
588
         *
589
         * @param array List of decorator names
590
         * @since 2015.10
591
         * @see mshop/common/manager/decorators/default
592
         * @see mshop/customer/manager/decorators/global
593
         * @see mshop/customer/manager/decorators/local
594
         */
595

596
        /** mshop/customer/manager/decorators/global
597
         * Adds a list of globally available decorators only to the customer manager
598
         *
599
         * Decorators extend the functionality of a class by adding new aspects
600
         * (e.g. log what is currently done), executing the methods of the underlying
601
         * class only in certain conditions (e.g. only for logged in users) or
602
         * modify what is returned to the caller.
603
         *
604
         * This option allows you to wrap global decorators
605
         * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the customer manager.
606
         *
607
         *  mshop/customer/manager/decorators/global = array( 'decorator1' )
608
         *
609
         * This would add the decorator named "decorator1" defined by
610
         * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the customer
611
         * manager.
612
         *
613
         * @param array List of decorator names
614
         * @since 2015.10
615
         * @see mshop/common/manager/decorators/default
616
         * @see mshop/customer/manager/decorators/excludes
617
         * @see mshop/customer/manager/decorators/local
618
         */
619

620
        /** mshop/customer/manager/decorators/local
621
         * Adds a list of local decorators only to the customer manager
622
         *
623
         * Decorators extend the functionality of a class by adding new aspects
624
         * (e.g. log what is currently done), executing the methods of the underlying
625
         * class only in certain conditions (e.g. only for logged in users) or
626
         * modify what is returned to the caller.
627
         *
628
         * This option allows you to wrap local decorators
629
         * ("\Aimeos\MShop\Customer\Manager\Decorator\*") around the customer manager.
630
         *
631
         *  mshop/customer/manager/decorators/local = array( 'decorator2' )
632
         *
633
         * This would add the decorator named "decorator2" defined by
634
         * "\Aimeos\MShop\Customer\Manager\Decorator\Decorator2" only to the customer
635
         * manager.
636
         *
637
         * @param array List of decorator names
638
         * @since 2015.10
639
         * @see mshop/common/manager/decorators/default
640
         * @see mshop/customer/manager/decorators/excludes
641
         * @see mshop/customer/manager/decorators/global
642
         */
643

644
        /** mshop/customer/manager/resource
645
         * Name of the database connection resource to use
646
         *
647
         * You can configure a different database connection for each data domain
648
         * and if no such connection name exists, the "db" connection will be used.
649
         * It's also possible to use the same database connection for different
650
         * data domains by configuring the same connection name using this setting.
651
         *
652
         * @param string Database connection name
653
         * @since 2023.04
654
         */
655

656
        /** mshop/customer/manager/submanagers
657
         * List of manager names that can be instantiated by the customer manager
658
         *
659
         * Managers provide a generic interface to the underlying storage.
660
         * Each manager has or can have sub-managers caring about particular
661
         * aspects. Each of these sub-managers can be instantiated by its
662
         * parent manager using the getSubManager() method.
663
         *
664
         * The search keys from sub-managers can be normally used in the
665
         * manager as well. It allows you to search for items of the manager
666
         * using the search keys of the sub-managers to further limit the
667
         * retrieved list of items.
668
         *
669
         * @param array List of sub-manager names
670
         * @since 2015.10
671
         */
672

673
        /** mshop/customer/manager/delete/mysql
674
         * Deletes the items matched by the given IDs from the database
675
         *
676
         * @see mshop/customer/manager/delete/ansi
677
         */
678

679
        /** mshop/customer/manager/delete/ansi
680
         * Deletes the items matched by the given IDs from the database
681
         *
682
         * Removes the records specified by the given IDs from the customer database.
683
         * The records must be from the site that is configured via the
684
         * context item.
685
         *
686
         * The ":cond" placeholder is replaced by the name of the ID column and
687
         * the given ID or list of IDs while the site ID is bound to the question
688
         * mark.
689
         *
690
         * The SQL statement should conform to the ANSI standard to be
691
         * compatible with most relational database systems. This also
692
         * includes using double quotes for table and column names.
693
         *
694
         * @param string SQL statement for deleting items
695
         * @since 2015.10
696
         * @see mshop/customer/manager/insert/ansi
697
         * @see mshop/customer/manager/update/ansi
698
         * @see mshop/customer/manager/newid/ansi
699
         * @see mshop/customer/manager/search/ansi
700
         * @see mshop/customer/manager/count/ansi
701
         */
702

703
        /** mshop/customer/manager/sitemode
704
         * Mode how items from levels below or above in the site tree are handled
705
         *
706
         * By default, only items from the current site are fetched from the
707
         * storage. If the ai-sites extension is installed, you can create a
708
         * tree of sites. Then, this setting allows you to define for the
709
         * whole customer domain if items from parent sites are inherited,
710
         * sites from child sites are aggregated or both.
711
         *
712
         * Available constants for the site mode are:
713
         * * 0 = only items from the current site
714
         * * 1 = inherit items from parent sites
715
         * * 2 = aggregate items from child sites
716
         * * 3 = inherit and aggregate items at the same time
717
         *
718
         * You also need to set the mode in the locale manager
719
         * (mshop/locale/manager/sitelevel) to one of the constants.
720
         * If you set it to the same value, it will work as described but you
721
         * can also use different modes. For example, if inheritance and
722
         * aggregation is configured the locale manager but only inheritance
723
         * in the domain manager because aggregating items makes no sense in
724
         * this domain, then items wil be only inherited. Thus, you have full
725
         * control over inheritance and aggregation in each domain.
726
         *
727
         * @param int Constant from Aimeos\MShop\Locale\Manager\Base class
728
         * @since 2018.01
729
         * @see mshop/locale/manager/sitelevel
730
         */
731

732
        /** mshop/customer/manager/search/mysql
733
         * Retrieves the records matched by the given criteria in the database
734
         *
735
         * @see mshop/customer/manager/search/ansi
736
         */
737

738
        /** mshop/customer/manager/search/ansi
739
         * Retrieves the records matched by the given criteria in the database
740
         *
741
         * Fetches the records matched by the given criteria from the customer
742
         * database. The records must be from one of the sites that are
743
         * configured via the context item. If the current site is part of
744
         * a tree of sites, the SELECT statement can retrieve all records
745
         * from the current site and the complete sub-tree of sites.
746
         *
747
         * As the records can normally be limited by criteria from sub-managers,
748
         * their tables must be joined in the SQL context. This is done by
749
         * using the "internaldeps" property from the definition of the ID
750
         * column of the sub-managers. These internal dependencies specify
751
         * the JOIN between the tables and the used columns for joining. The
752
         * ":joins" placeholder is then replaced by the JOIN strings from
753
         * the sub-managers.
754
         *
755
         * To limit the records matched, conditions can be added to the given
756
         * criteria object. It can contain comparisons like column names that
757
         * must match specific values which can be combined by AND, OR or NOT
758
         * operators. The resulting string of SQL conditions replaces the
759
         * ":cond" placeholder before the statement is sent to the database
760
         * server.
761
         *
762
         * If the records that are retrieved should be ordered by one or more
763
         * columns, the generated string of column / sort direction pairs
764
         * replaces the ":order" placeholder. Columns of
765
         * sub-managers can also be used for ordering the result set but then
766
         * no index can be used.
767
         *
768
         * The number of returned records can be limited and can start at any
769
         * number between the begining and the end of the result set. For that
770
         * the ":size" and ":start" placeholders are replaced by the
771
         * corresponding values from the criteria object. The default values
772
         * are 0 for the start and 100 for the size value.
773
         *
774
         * The SQL statement should conform to the ANSI standard to be
775
         * compatible with most relational database systems. This also
776
         * includes using double quotes for table and column names.
777
         *
778
         * @param string SQL statement for searching items
779
         * @since 2015.10
780
         * @see mshop/customer/manager/insert/ansi
781
         * @see mshop/customer/manager/update/ansi
782
         * @see mshop/customer/manager/newid/ansi
783
         * @see mshop/customer/manager/delete/ansi
784
         * @see mshop/customer/manager/count/ansi
785
         */
786

787
        /** mshop/customer/manager/count/mysql
788
         * Counts the number of records matched by the given criteria in the database
789
         *
790
         * @see mshop/customer/manager/count/ansi
791
         */
792

793
        /** mshop/customer/manager/count/ansi
794
         * Counts the number of records matched by the given criteria in the database
795
         *
796
         * Counts all records matched by the given criteria from the customer
797
         * database. The records must be from one of the sites that are
798
         * configured via the context item. If the current site is part of
799
         * a tree of sites, the statement can count all records from the
800
         * current site and the complete sub-tree of sites.
801
         *
802
         * As the records can normally be limited by criteria from sub-managers,
803
         * their tables must be joined in the SQL context. This is done by
804
         * using the "internaldeps" property from the definition of the ID
805
         * column of the sub-managers. These internal dependencies specify
806
         * the JOIN between the tables and the used columns for joining. The
807
         * ":joins" placeholder is then replaced by the JOIN strings from
808
         * the sub-managers.
809
         *
810
         * To limit the records matched, conditions can be added to the given
811
         * criteria object. It can contain comparisons like column names that
812
         * must match specific values which can be combined by AND, OR or NOT
813
         * operators. The resulting string of SQL conditions replaces the
814
         * ":cond" placeholder before the statement is sent to the database
815
         * server.
816
         *
817
         * Both, the strings for ":joins" and for ":cond" are the same as for
818
         * the "search" SQL statement.
819
         *
820
         * Contrary to the "search" statement, it doesn't return any records
821
         * but instead the number of records that have been found. As counting
822
         * thousands of records can be a long running task, the maximum number
823
         * of counted records is limited for performance reasons.
824
         *
825
         * The SQL statement should conform to the ANSI standard to be
826
         * compatible with most relational database systems. This also
827
         * includes using double quotes for table and column names.
828
         *
829
         * @param string SQL statement for counting items
830
         * @since 2015.10
831
         * @see mshop/customer/manager/insert/ansi
832
         * @see mshop/customer/manager/update/ansi
833
         * @see mshop/customer/manager/newid/ansi
834
         * @see mshop/customer/manager/delete/ansi
835
         * @see mshop/customer/manager/search/ansi
836
         */
837
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc