Passed
Push — master ( e4a92d...0988af )
by Aimeos
04:33
created

Standard::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 16
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
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 Supplier
8
 */
9
10
11
namespace Aimeos\MShop\Supplier\Manager\Address;
12
13
14
/**
15
 * Implementation for supplier address manager.
16
 *
17
 * @package MShop
18
 * @subpackage Supplier
19
 */
20
class Standard
21
	extends \Aimeos\MShop\Common\Manager\Address\Base
22
	implements \Aimeos\MShop\Supplier\Manager\Address\Iface
23
{
24
	/**
25
	 * Creates a new empty item instance
26
	 *
27
	 * @param array $values Values the item should be initialized with
28
	 * @return \Aimeos\MShop\Order\Item\Address\Iface New order address item object
29
	 */
30
	public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
31
	{
32
		$values['supplier.address.siteid'] = $values['supplier.address.siteid'] ?? $this->context()->locale()->getSiteId();
33
34
		return new \Aimeos\MShop\Supplier\Item\Address\Standard( 'supplier.address.', $values );
35
	}
36
37
38
	/**
39
	 * Returns the attributes that can be used for searching.
40
	 *
41
	 * @param bool $withsub Return also attributes of sub-managers if true
42
	 * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items
43
	 */
44
	public function getSearchAttributes( bool $withsub = true ) : array
45
	{
46
		return array_replace( parent::getSearchAttributes( $withsub ), $this->createAttributes( [
47
			'supplier.address.id' => [
48
				'label' => 'Supplier address ID',
49
				'internalcode' => 'id',
50
				'internaldeps' => ['LEFT JOIN "mshop_supplier_address" AS msupad ON ( msup."id" = msupad."parentid" )'],
51
				'type' => 'int',
52
				'public' => false,
53
			]
54
		] ) );
55
	}
56
57
58
	/**
59
	 * Returns the prefix for the item properties and search keys.
60
	 *
61
	 * @return string Prefix for the item properties and search keys
62
	 */
63
	protected function prefix() : string
64
	{
65
		return 'supplier.address.';
66
	}
67
68
69
	/** mshop/supplier/manager/address/name
70
	 * Class name of the used supplier address manager implementation
71
	 *
72
	 * Each default supplier address manager can be replaced by an alternative imlementation.
73
	 * To use this implementation, you have to set the last part of the class
74
	 * name as configuration value so the manager factory knows which class it
75
	 * has to instantiate.
76
	 *
77
	 * For example, if the name of the default class is
78
	 *
79
	 *  \Aimeos\MShop\Supplier\Manager\Address\Standard
80
	 *
81
	 * and you want to replace it with your own version named
82
	 *
83
	 *  \Aimeos\MShop\Supplier\Manager\Address\Myaddress
84
	 *
85
	 * then you have to set the this configuration option:
86
	 *
87
	 *  mshop/supplier/manager/address/name = Myaddress
88
	 *
89
	 * The value is the last part of your own class name and it's case sensitive,
90
	 * so take care that the configuration value is exactly named like the last
91
	 * part of the class name.
92
	 *
93
	 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
94
	 * characters are possible! You should always start the last part of the class
95
	 * name with an upper case character and continue only with lower case characters
96
	 * or numbers. Avoid chamel case names like "MyAddress"!
97
	 *
98
	 * @param string Last part of the class name
99
	 * @since 2015.10
100
	 */
101
102
	/** mshop/supplier/manager/address/decorators/excludes
103
	 * Excludes decorators added by the "common" option from the supplier address manager
104
	 *
105
	 * Decorators extend the functionality of a class by adding new aspects
106
	 * (e.g. log what is currently done), executing the methods of the underlying
107
	 * class only in certain conditions (e.g. only for logged in users) or
108
	 * modify what is returned to the caller.
109
	 *
110
	 * This option allows you to remove a decorator added via
111
	 * "mshop/common/manager/decorators/default" before they are wrapped
112
	 * around the supplier address manager.
113
	 *
114
	 *  mshop/supplier/manager/address/decorators/excludes = array( 'decorator1' )
115
	 *
116
	 * This would remove the decorator named "decorator1" from the list of
117
	 * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
118
	 * "mshop/common/manager/decorators/default" for the supplier address manager.
119
	 *
120
	 * @param array Address of decorator names
121
	 * @since 2015.10
122
	 * @see mshop/common/manager/decorators/default
123
	 * @see mshop/supplier/manager/address/decorators/global
124
	 * @see mshop/supplier/manager/address/decorators/local
125
	 */
126
127
	/** mshop/supplier/manager/address/decorators/global
128
	 * Adds a list of globally available decorators only to the supplier address manager
129
	 *
130
	 * Decorators extend the functionality of a class by adding new aspects
131
	 * (e.g. log what is currently done), executing the methods of the underlying
132
	 * class only in certain conditions (e.g. only for logged in users) or
133
	 * modify what is returned to the caller.
134
	 *
135
	 * This option allows you to wrap global decorators
136
	 * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the supplier address manager.
137
	 *
138
	 *  mshop/supplier/manager/address/decorators/global = array( 'decorator1' )
139
	 *
140
	 * This would add the decorator named "decorator1" defined by
141
	 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the supplier
142
	 * address manager.
143
	 *
144
	 * @param array Address of decorator names
145
	 * @since 2015.10
146
	 * @see mshop/common/manager/decorators/default
147
	 * @see mshop/supplier/manager/address/decorators/excludes
148
	 * @see mshop/supplier/manager/address/decorators/local
149
	 */
150
151
	/** mshop/supplier/manager/address/decorators/local
152
	 * Adds a list of local decorators only to the supplier address manager
153
	 *
154
	 * Decorators extend the functionality of a class by adding new aspects
155
	 * (e.g. log what is currently done), executing the methods of the underlying
156
	 * class only in certain conditions (e.g. only for logged in users) or
157
	 * modify what is returned to the caller.
158
	 *
159
	 * This option allows you to wrap local decorators
160
	 * ("\Aimeos\MShop\Supplier\Manager\Address\Decorator\*") around the supplier
161
	 * address manager.
162
	 *
163
	 *  mshop/supplier/manager/address/decorators/local = array( 'decorator2' )
164
	 *
165
	 * This would add the decorator named "decorator2" defined by
166
	 * "\Aimeos\MShop\Supplier\Manager\Address\Decorator\Decorator2" only to the
167
	 * supplier address manager.
168
	 *
169
	 * @param array Address of decorator names
170
	 * @since 2015.10
171
	 * @see mshop/common/manager/decorators/default
172
	 * @see mshop/supplier/manager/address/decorators/excludes
173
	 * @see mshop/supplier/manager/address/decorators/global
174
	 */
175
176
	/** mshop/supplier/manager/address/submanagers
177
	 * List of manager names that can be instantiated by the supplier address manager
178
	 *
179
	 * Managers provide a generic interface to the underlying storage.
180
	 * Each manager has or can have sub-managers caring about particular
181
	 * aspects. Each of these sub-managers can be instantiated by its
182
	 * parent manager using the getSubManager() method.
183
	 *
184
	 * The search keys from sub-managers can be normally used in the
185
	 * manager as well. It allows you to search for items of the manager
186
	 * using the search keys of the sub-managers to further limit the
187
	 * retrieved list of items.
188
	 *
189
	 * @param array List of sub-manager names
190
	 * @since 2015.10
191
	 */
192
193
	/** mshop/supplier/manager/address/insert/mysql
194
	 * Inserts a new supplier address record into the database table
195
	 *
196
	 * @see mshop/supplier/manager/address/insert/ansi
197
	 */
198
199
	/** mshop/supplier/manager/address/insert/ansi
200
	 * Inserts a new supplier address record into the database table
201
	 *
202
	 * Items with no ID yet (i.e. the ID is NULL) will be created in
203
	 * the database and the newly created ID retrieved afterwards
204
	 * using the "newid" SQL statement.
205
	 *
206
	 * The SQL statement must be a string suitable for being used as
207
	 * prepared statement. It must include question marks for binding
208
	 * the values from the supplier list item to the statement before they are
209
	 * sent to the database server. The number of question marks must
210
	 * be the same as the number of columns listed in the INSERT
211
	 * statement. The order of the columns must correspond to the
212
	 * order in the save() method, so the correct values are
213
	 * bound to the columns.
214
	 *
215
	 * The SQL statement should conform to the ANSI standard to be
216
	 * compatible with most relational database systems. This also
217
	 * includes using double quotes for table and column names.
218
	 *
219
	 * @param string SQL statement for inserting records
220
	 * @since 2015.10
221
	 * @see mshop/supplier/manager/address/update/ansi
222
	 * @see mshop/supplier/manager/address/newid/ansi
223
	 * @see mshop/supplier/manager/address/delete/ansi
224
	 * @see mshop/supplier/manager/address/search/ansi
225
	 * @see mshop/supplier/manager/address/count/ansi
226
	 */
227
228
	/** mshop/supplier/manager/address/update/mysql
229
	 * Updates an existing supplier address record in the database
230
	 *
231
	 * @see mshop/supplier/manager/address/update/ansi
232
	 */
233
234
	/** mshop/supplier/manager/address/update/ansi
235
	 * Updates an existing supplier address record in the database
236
	 *
237
	 * Items which already have an ID (i.e. the ID is not NULL) will
238
	 * be updated in the database.
239
	 *
240
	 * The SQL statement must be a string suitable for being used as
241
	 * prepared statement. It must include question marks for binding
242
	 * the values from the supplier list item to the statement before they are
243
	 * sent to the database server. The order of the columns must
244
	 * correspond to the order in the save() method, so the
245
	 * correct values are bound to the columns.
246
	 *
247
	 * The SQL statement should conform to the ANSI standard to be
248
	 * compatible with most relational database systems. This also
249
	 * includes using double quotes for table and column names.
250
	 *
251
	 * @param string SQL statement for updating records
252
	 * @since 2015.10
253
	 * @see mshop/supplier/manager/address/insert/ansi
254
	 * @see mshop/supplier/manager/address/newid/ansi
255
	 * @see mshop/supplier/manager/address/delete/ansi
256
	 * @see mshop/supplier/manager/address/search/ansi
257
	 * @see mshop/supplier/manager/address/count/ansi
258
	 */
259
260
	/** mshop/supplier/manager/address/newid/mysql
261
	 * Retrieves the ID generated by the database when inserting a new record
262
	 *
263
	 * @see mshop/supplier/manager/address/newid/ansi
264
	 */
265
266
	/** mshop/supplier/manager/address/newid/ansi
267
	 * Retrieves the ID generated by the database when inserting a new record
268
	 *
269
	 * As soon as a new record is inserted into the database table,
270
	 * the database server generates a new and unique identifier for
271
	 * that record. This ID can be used for retrieving, updating and
272
	 * deleting that specific record from the table again.
273
	 *
274
	 * For MySQL:
275
	 *  SELECT LAST_INSERT_ID()
276
	 * For PostgreSQL:
277
	 *  SELECT currval('seq_mcusad_id')
278
	 * For SQL Server:
279
	 *  SELECT SCOPE_IDENTITY()
280
	 * For Oracle:
281
	 *  SELECT "seq_mcusad_id".CURRVAL FROM DUAL
282
	 *
283
	 * There's no way to retrive the new ID by a SQL statements that
284
	 * fits for most database servers as they implement their own
285
	 * specific way.
286
	 *
287
	 * @param string SQL statement for retrieving the last inserted record ID
288
	 * @since 2015.10
289
	 * @see mshop/supplier/manager/address/insert/ansi
290
	 * @see mshop/supplier/manager/address/update/ansi
291
	 * @see mshop/supplier/manager/address/delete/ansi
292
	 * @see mshop/supplier/manager/address/search/ansi
293
	 * @see mshop/supplier/manager/address/count/ansi
294
	 */
295
296
	/** mshop/supplier/manager/address/delete/mysql
297
	 * Deletes the items matched by the given IDs from the database
298
	 *
299
	 * @see mshop/supplier/manager/address/delete/ansi
300
	 */
301
302
	/** mshop/supplier/manager/address/delete/ansi
303
	 * Deletes the items matched by the given IDs from the database
304
	 *
305
	 * Removes the records specified by the given IDs from the supplier database.
306
	 * The records must be from the site that is configured via the
307
	 * context item.
308
	 *
309
	 * The ":cond" placeholder is replaced by the name of the ID column and
310
	 * the given ID or list of IDs while the site ID is bound to the question
311
	 * mark.
312
	 *
313
	 * The SQL statement should conform to the ANSI standard to be
314
	 * compatible with most relational database systems. This also
315
	 * includes using double quotes for table and column names.
316
	 *
317
	 * @param string SQL statement for deleting items
318
	 * @since 2015.10
319
	 * @see mshop/supplier/manager/address/insert/ansi
320
	 * @see mshop/supplier/manager/address/update/ansi
321
	 * @see mshop/supplier/manager/address/newid/ansi
322
	 * @see mshop/supplier/manager/address/search/ansi
323
	 * @see mshop/supplier/manager/address/count/ansi
324
	 */
325
326
	/** mshop/supplier/manager/address/search/mysql
327
	 * Retrieves the records matched by the given criteria in the database
328
	 *
329
	 * @see mshop/supplier/manager/address/search/ansi
330
	 */
331
332
	/** mshop/supplier/manager/address/search/ansi
333
	 * Retrieves the records matched by the given criteria in the database
334
	 *
335
	 * Fetches the records matched by the given criteria from the supplier
336
	 * database. The records must be from one of the sites that are
337
	 * configured via the context item. If the current site is part of
338
	 * a tree of sites, the SELECT statement can retrieve all records
339
	 * from the current site and the complete sub-tree of sites.
340
	 *
341
	 * As the records can normally be limited by criteria from sub-managers,
342
	 * their tables must be joined in the SQL context. This is done by
343
	 * using the "internaldeps" property from the definition of the ID
344
	 * column of the sub-managers. These internal dependencies specify
345
	 * the JOIN between the tables and the used columns for joining. The
346
	 * ":joins" placeholder is then replaced by the JOIN strings from
347
	 * the sub-managers.
348
	 *
349
	 * To limit the records matched, conditions can be added to the given
350
	 * criteria object. It can contain comparisons like column names that
351
	 * must match specific values which can be combined by AND, OR or NOT
352
	 * operators. The resulting string of SQL conditions replaces the
353
	 * ":cond" placeholder before the statement is sent to the database
354
	 * server.
355
	 *
356
	 * If the records that are retrieved should be ordered by one or more
357
	 * columns, the generated string of column / sort direction pairs
358
	 * replaces the ":order" placeholder. Columns of
359
	 * sub-managers can also be used for ordering the result set but then
360
	 * no index can be used.
361
	 *
362
	 * The number of returned records can be limited and can start at any
363
	 * number between the begining and the end of the result set. For that
364
	 * the ":size" and ":start" placeholders are replaced by the
365
	 * corresponding values from the criteria object. The default values
366
	 * are 0 for the start and 100 for the size value.
367
	 *
368
	 * The SQL statement should conform to the ANSI standard to be
369
	 * compatible with most relational database systems. This also
370
	 * includes using double quotes for table and column names.
371
	 *
372
	 * @param string SQL statement for searching items
373
	 * @since 2015.10
374
	 * @see mshop/supplier/manager/address/insert/ansi
375
	 * @see mshop/supplier/manager/address/update/ansi
376
	 * @see mshop/supplier/manager/address/newid/ansi
377
	 * @see mshop/supplier/manager/address/delete/ansi
378
	 * @see mshop/supplier/manager/address/count/ansi
379
	 */
380
381
	/** mshop/supplier/manager/address/count/mysql
382
	 * Counts the number of records matched by the given criteria in the database
383
	 *
384
	 * @see mshop/supplier/manager/address/count/ansi
385
	 */
386
387
	/** mshop/supplier/manager/address/count/ansi
388
	 * Counts the number of records matched by the given criteria in the database
389
	 *
390
	 * Counts all records matched by the given criteria from the supplier
391
	 * database. The records must be from one of the sites that are
392
	 * configured via the context item. If the current site is part of
393
	 * a tree of sites, the statement can count all records from the
394
	 * current site and the complete sub-tree of sites.
395
	 *
396
	 * As the records can normally be limited by criteria from sub-managers,
397
	 * their tables must be joined in the SQL context. This is done by
398
	 * using the "internaldeps" property from the definition of the ID
399
	 * column of the sub-managers. These internal dependencies specify
400
	 * the JOIN between the tables and the used columns for joining. The
401
	 * ":joins" placeholder is then replaced by the JOIN strings from
402
	 * the sub-managers.
403
	 *
404
	 * To limit the records matched, conditions can be added to the given
405
	 * criteria object. It can contain comparisons like column names that
406
	 * must match specific values which can be combined by AND, OR or NOT
407
	 * operators. The resulting string of SQL conditions replaces the
408
	 * ":cond" placeholder before the statement is sent to the database
409
	 * server.
410
	 *
411
	 * Both, the strings for ":joins" and for ":cond" are the same as for
412
	 * the "search" SQL statement.
413
	 *
414
	 * Contrary to the "search" statement, it doesn't return any records
415
	 * but instead the number of records that have been found. As counting
416
	 * thousands of records can be a long running task, the maximum number
417
	 * of counted records is limited for performance reasons.
418
	 *
419
	 * The SQL statement should conform to the ANSI standard to be
420
	 * compatible with most relational database systems. This also
421
	 * includes using double quotes for table and column names.
422
	 *
423
	 * @param string SQL statement for counting items
424
	 * @since 2015.10
425
	 * @see mshop/supplier/manager/address/insert/ansi
426
	 * @see mshop/supplier/manager/address/update/ansi
427
	 * @see mshop/supplier/manager/address/newid/ansi
428
	 * @see mshop/supplier/manager/address/delete/ansi
429
	 * @see mshop/supplier/manager/address/search/ansi
430
	 */
431
}
432