Passed
Push — master ( 44c1d8...6b9f69 )
by Aimeos
16:18
created

Standard::createItemBase()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @license LGPLv3, https://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2011
6
 * @copyright Aimeos (aimeos.org), 2015-2023
7
 * @package MShop
8
 * @subpackage Locale
9
 */
10
11
12
namespace Aimeos\MShop\Locale\Manager\Currency;
13
14
15
/**
16
 * Default implementation for managing currencies.
17
 *
18
 * @package MShop
19
 * @subpackage Locale
20
 */
21
class Standard
22
	extends \Aimeos\MShop\Common\Manager\Base
23
	implements \Aimeos\MShop\Locale\Manager\Currency\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
24
{
25
	private array $searchConfig = array(
26
		'locale.currency.id' => array(
27
			'code' => 'locale.currency.id',
28
			'internalcode' => 'mloccu."id"',
29
			'internaldeps' => array( 'LEFT JOIN "mshop_locale_currency" AS mloccu ON (mloc."currencyid" = mloccu."id")' ),
30
			'label' => 'Currency ID',
31
			'public' => false,
32
		),
33
		'locale.currency.label' => array(
34
			'code' => 'locale.currency.label',
35
			'internalcode' => 'mloccu."label"',
36
			'label' => 'Currency label',
37
		),
38
		'locale.currency.code' => array(
39
			'code' => 'locale.currency.code',
40
			'internalcode' => 'mloccu."id"',
41
			'label' => 'Currency code',
42
		),
43
		'locale.currency.status' => array(
44
			'code' => 'locale.currency.status',
45
			'internalcode' => 'mloccu."status"',
46
			'label' => 'Currency status',
47
			'type' => 'int',
48
		),
49
		'locale.currency.ctime' => array(
50
			'code' => 'locale.currency.ctime',
51
			'internalcode' => 'mloccu."ctime"',
52
			'label' => 'Currency create date/time',
53
			'type' => 'datetime',
54
			'public' => false,
55
		),
56
		'locale.currency.mtime' => array(
57
			'code' => 'locale.currency.mtime',
58
			'internalcode' => 'mloccu."mtime"',
59
			'label' => 'Currency modify date/time',
60
			'type' => 'datetime',
61
			'public' => false,
62
		),
63
		'locale.currency.editor' => array(
64
			'code' => 'locale.currency.editor',
65
			'internalcode' => 'mloccu."editor"',
66
			'label' => 'Currency editor',
67
			'public' => false,
68
		),
69
	);
70
71
72
	/**
73
	 * Initializes the object.
74
	 *
75
	 * @param \Aimeos\MShop\ContextIface $context Context object
76
	 */
77
	public function __construct( \Aimeos\MShop\ContextIface $context )
78
	{
79
		parent::__construct( $context );
80
81
		/** mshop/locale/manager/resource
82
		 * Name of the database connection resource to use
83
		 *
84
		 * You can configure a different database connection for each data domain
85
		 * and if no such connection name exists, the "db" connection will be used.
86
		 * It's also possible to use the same database connection for different
87
		 * data domains by configuring the same connection name using this setting.
88
		 *
89
		 * @param string Database connection name
90
		 * @since 2023.04
91
		 */
92
		$this->setResourceName( $context->config()->get( 'mshop/locale/manager/resource', 'db-locale' ) );
93
	}
94
95
96
	/**
97
	 * Removes old entries from the storage.
98
	 *
99
	 * @param iterable $siteids List of IDs for sites whose entries should be deleted
100
	 * @return \Aimeos\MShop\Locale\Manager\Iface Manager object for chaining method calls
101
	 */
102
	public function clear( iterable $siteids ) : \Aimeos\MShop\Common\Manager\Iface
103
	{
104
		return $this;
105
	}
106
107
108
	/**
109
	 * Creates a new empty item instance
110
	 *
111
	 * @param array $values Values the item should be initialized with
112
	 * @return \Aimeos\MShop\Locale\Item\Currency\Iface New locale currency item object
113
	 */
114
	public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
115
	{
116
		try {
117
			$values['locale.currency.siteid'] = $this->context()->locale()->getSiteId();
118
		} catch( \Exception $e ) {
119
			$values['locale.currency.siteid'] = null;
120
		}
121
122
		return $this->createItemBase( $values );
123
	}
124
125
126
	/**
127
	 * Saves a currency item to the storage.
128
	 *
129
	 * @param \Aimeos\MShop\Locale\Item\Currency\Iface $item Currency item to save in the storage
130
	 * @param bool $fetch True if the new ID should be returned in the item
131
	 * @return \Aimeos\MShop\Locale\Item\Currency\Iface $item Updated item including the generated ID
132
	 */
133
	protected function saveItem( \Aimeos\MShop\Locale\Item\Currency\Iface $item, bool $fetch = true ) : \Aimeos\MShop\Locale\Item\Currency\Iface
134
	{
135
		if( !$item->isModified() ) {
136
			return $item;
137
		}
138
139
		$context = $this->context();
140
		$conn = $context->db( $this->getResourceName() );
141
142
		$id = $item->getId();
143
		$date = date( 'Y-m-d H:i:s' );
144
		$columns = $this->object()->getSaveAttributes();
145
146
		if( $id === null )
147
		{
148
			/** mshop/locale/manager/currency/insert/mysql
149
			 * Inserts a new currency record into the database table
150
			 *
151
			 * @see mshop/locale/manager/currency/insert/ansi
152
			 */
153
154
			/** mshop/locale/manager/currency/insert/ansi
155
			 * Inserts a new currency record into the database table
156
			 *
157
			 * The SQL statement must be a string suitable for being used as
158
			 * prepared statement. It must include question marks for binding
159
			 * the values from the currency item to the statement before they are
160
			 * sent to the database server. The number of question marks must
161
			 * be the same as the number of columns listed in the INSERT
162
			 * statement. The order of the columns must correspond to the
163
			 * order in the save() method, so the correct values are
164
			 * bound to the columns.
165
			 *
166
			 * The SQL statement should conform to the ANSI standard to be
167
			 * compatible with most relational database systems. This also
168
			 * includes using double quotes for table and column names.
169
			 *
170
			 * @param string SQL statement for inserting records
171
			 * @since 2014.03
172
			 * @category Developer
173
			 * @see mshop/locale/manager/currency/update/ansi
174
			 * @see mshop/locale/manager/currency/delete/ansi
175
			 * @see mshop/locale/manager/currency/search/ansi
176
			 * @see mshop/locale/manager/currency/count/ansi
177
			 */
178
			$path = 'mshop/locale/manager/currency/insert';
179
			$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ) );
0 ignored issues
show
Bug introduced by
It seems like $this->getSqlConfig($path) can also be of type array; however, parameter $sql of Aimeos\MShop\Common\Manager\Base::addSqlColumns() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

179
			$sql = $this->addSqlColumns( array_keys( $columns ), /** @scrutinizer ignore-type */ $this->getSqlConfig( $path ) );
Loading history...
180
		}
181
		else
182
		{
183
			/** mshop/locale/manager/currency/update/mysql
184
			 * Updates an existing currency record in the database
185
			 *
186
			 * @see mshop/locale/manager/currency/update/ansi
187
			 */
188
189
			/** mshop/locale/manager/currency/update/ansi
190
			 * Updates an existing currency record in the database
191
			 *
192
			 * The SQL statement must be a string suitable for being used as
193
			 * prepared statement. It must include question marks for binding
194
			 * the values from the currency item to the statement before they are
195
			 * sent to the database server. The order of the columns must
196
			 * correspond to the order in the save() method, so the
197
			 * correct values are bound to the columns.
198
			 *
199
			 * The SQL statement should conform to the ANSI standard to be
200
			 * compatible with most relational database systems. This also
201
			 * includes using double quotes for table and column names.
202
			 *
203
			 * @param string SQL statement for updating records
204
			 * @since 2014.03
205
			 * @category Developer
206
			 * @see mshop/locale/manager/currency/insert/ansi
207
			 * @see mshop/locale/manager/currency/delete/ansi
208
			 * @see mshop/locale/manager/currency/search/ansi
209
			 * @see mshop/locale/manager/currency/count/ansi
210
			 */
211
			$path = 'mshop/locale/manager/currency/update';
212
			$sql = $this->addSqlColumns( array_keys( $columns ), $this->getSqlConfig( $path ), false );
213
		}
214
215
		$idx = 1;
216
		$stmt = $this->getCachedStatement( $conn, $path, $sql );
217
218
		foreach( $columns as $name => $entry ) {
219
			$stmt->bind( $idx++, $item->get( $name ), \Aimeos\Base\Criteria\SQL::type( $entry->getType() ) );
220
		}
221
222
		$stmt->bind( $idx++, $item->getLabel() );
223
		$stmt->bind( $idx++, $item->getStatus(), \Aimeos\Base\DB\Statement\Base::PARAM_INT );
224
		$stmt->bind( $idx++, $date ); // mtime
225
		$stmt->bind( $idx++, $context->editor() );
226
		// bind ID but code and id are identical after saveing the stuff
227
		// id is the flag to detect updates or inserts!
228
		$stmt->bind( $idx++, $item->getCode() );
229
230
		if( $id === null ) {
231
			$stmt->bind( $idx++, $date ); // ctime
232
		}
233
234
		$stmt->execute()->finish();
235
236
		$item->setId( $item->getCode() ); // set modified flag to false
237
238
		return $item;
239
	}
240
241
242
	/**
243
	 * Removes multiple items.
244
	 *
245
	 * @param \Aimeos\MShop\Common\Item\Iface[]|string[] $itemIds List of item objects or IDs of the items
246
	 * @return \Aimeos\MShop\Locale\Manager\Currency\Iface Manager object for chaining method calls
247
	 */
248
	public function delete( $itemIds ) : \Aimeos\MShop\Common\Manager\Iface
249
	{
250
		/** mshop/locale/manager/currency/delete/mysql
251
		 * Deletes the items matched by the given IDs from the database
252
		 *
253
		 * @see mshop/locale/manager/currency/delete/ansi
254
		 */
255
256
		/** mshop/locale/manager/currency/delete/ansi
257
		 * Deletes the items matched by the given IDs from the database
258
		 *
259
		 * Removes the language records specified by the given IDs from the
260
		 * locale database. The records must be from the site that is configured
261
		 * via the context item.
262
		 *
263
		 * The ":cond" placeholder is replaced by the name of the ID column and
264
		 * the given ID or list of IDs while the site ID is bound to the question
265
		 * mark.
266
		 *
267
		 * The SQL statement should conform to the ANSI standard to be
268
		 * compatible with most relational database systems. This also
269
		 * includes using double quotes for table and column names.
270
		 *
271
		 * @param string SQL statement for deleting items
272
		 * @since 2014.03
273
		 * @category Developer
274
		 * @see mshop/locale/manager/currency/insert/ansi
275
		 * @see mshop/locale/manager/currency/update/ansi
276
		 * @see mshop/locale/manager/currency/search/ansi
277
		 * @see mshop/locale/manager/currency/count/ansi
278
		 */
279
		$path = 'mshop/locale/manager/currency/delete';
280
281
		return $this->deleteItemsBase( $itemIds, $path, false );
282
	}
283
284
285
	/**
286
	 * Returns the currency object with the given currency ID.
287
	 *
288
	 * @param string $id Currency ID indentifying the currency object
289
	 * @param string[] $ref List of domains to fetch list items and referenced items for
290
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
291
	 * @return \Aimeos\MShop\Locale\Item\Currency\Iface Returns the currency item of the given id
292
	 * @throws \Aimeos\MShop\Exception If item couldn't be found
293
	 */
294
	public function get( string $id, array $ref = [], ?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
295
	{
296
		return $this->getItemBase( 'locale.currency.id', $id, $ref, $default );
297
	}
298
299
300
	/**
301
	 * Returns the available manager types
302
	 *
303
	 * @param bool $withsub Return also the resource type of sub-managers if true
304
	 * @return string[] Type of the manager and submanagers, subtypes are separated by slashes
305
	 */
306
	public function getResourceType( bool $withsub = true ) : array
307
	{
308
		$path = 'mshop/locale/manager/currency/submanagers';
309
		return $this->getResourceTypeBase( 'locale/currency', $path, [], $withsub );
310
	}
311
312
313
	/**
314
	 * Returns the attributes that can be used for searching.
315
	 *
316
	 * @param bool $withsub Return also attributes of sub-managers if true
317
	 * @return \Aimeos\Base\Criteria\Attribute\Iface[] List of search attribute items
318
	 */
319
	public function getSearchAttributes( bool $withsub = true ) : array
320
	{
321
		/** mshop/locale/manager/currency/submanagers
322
		 * List of manager names that can be instantiated by the locale currency manager
323
		 *
324
		 * Managers provide a generic interface to the underlying storage.
325
		 * Each manager has or can have sub-managers caring about particular
326
		 * aspects. Each of these sub-managers can be instantiated by its
327
		 * parent manager using the getSubManager() method.
328
		 *
329
		 * The search keys from sub-managers can be normally used in the
330
		 * manager as well. It allows you to search for items of the manager
331
		 * using the search keys of the sub-managers to further limit the
332
		 * retrieved list of items.
333
		 *
334
		 * @param array List of sub-manager names
335
		 * @since 2014.03
336
		 * @category Developer
337
		 */
338
		$path = 'mshop/locale/manager/currency/submanagers';
339
340
		return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub );
341
	}
342
343
344
	/**
345
	 * Search for currency items matching the given criteria.
346
	 *
347
	 * @param \Aimeos\Base\Criteria\Iface $search Search criteria object
348
	 * @param string[] $ref List of domains to fetch list items and referenced items for
349
	 * @param int|null &$total Number of items that are available in total
350
	 * @return \Aimeos\Map List of items imlementing \Aimeos\MShop\Locale\Item\Currency\Iface with ids as keys
351
	 */
352
	public function search( \Aimeos\Base\Criteria\Iface $search, array $ref = [], int &$total = null ) : \Aimeos\Map
353
	{
354
		$items = [];
355
		$context = $this->context();
356
		$conn = $context->db( $this->getResourceName() );
357
358
		$required = ['locale.currency'];
359
360
		/** mshop/locale/manager/currency/search/mysql
361
		 * Retrieves the records matched by the given criteria in the database
362
		 *
363
		 * @see mshop/locale/manager/currency/search/ansi
364
		 */
365
366
		/** mshop/locale/manager/currency/search/ansi
367
		 * Retrieves the records matched by the given criteria in the database
368
		 *
369
		 * Fetches the records matched by the given criteria from the attribute
370
		 * database. The records must be from one of the sites that are
371
		 * configured via the context item. If the current site is part of
372
		 * a tree of sites, the SELECT statement can retrieve all records
373
		 * from the current site and the complete sub-tree of sites.
374
		 *
375
		 * As the records can normally be limited by criteria from sub-managers,
376
		 * their tables must be joined in the SQL context. This is done by
377
		 * using the "internaldeps" property from the definition of the ID
378
		 * column of the sub-managers. These internal dependencies specify
379
		 * the JOIN between the tables and the used columns for joining. The
380
		 * ":joins" placeholder is then replaced by the JOIN strings from
381
		 * the sub-managers.
382
		 *
383
		 * To limit the records matched, conditions can be added to the given
384
		 * criteria object. It can contain comparisons like column names that
385
		 * must match specific values which can be combined by AND, OR or NOT
386
		 * operators. The resulting string of SQL conditions replaces the
387
		 * ":cond" placeholder before the statement is sent to the database
388
		 * server.
389
		 *
390
		 * If the records that are retrieved should be ordered by one or more
391
		 * columns, the generated string of column / sort direction pairs
392
		 * replaces the ":order" placeholder. In case no ordering is required,
393
		 * the complete ORDER BY part including the "\/*-orderby*\/...\/*orderby-*\/"
394
		 * markers is removed to speed up retrieving the records. Columns of
395
		 * sub-managers can also be used for ordering the result set but then
396
		 * no index can be used.
397
		 *
398
		 * The number of returned records can be limited and can start at any
399
		 * number between the begining and the end of the result set. For that
400
		 * the ":size" and ":start" placeholders are replaced by the
401
		 * corresponding values from the criteria object. The default values
402
		 * are 0 for the start and 100 for the size value.
403
		 *
404
		 * The SQL statement should conform to the ANSI standard to be
405
		 * compatible with most relational database systems. This also
406
		 * includes using double quotes for table and column names.
407
		 *
408
		 * @param string SQL statement for searching items
409
		 * @since 2014.03
410
		 * @category Developer
411
		 * @see mshop/locale/manager/currency/insert/ansi
412
		 * @see mshop/locale/manager/currency/update/ansi
413
		 * @see mshop/locale/manager/currency/delete/ansi
414
		 * @see mshop/locale/manager/currency/count/ansi
415
		 */
416
		$cfgPathSearch = 'mshop/locale/manager/currency/search';
417
418
		/** mshop/locale/manager/currency/count/mysql
419
		 * Counts the number of records matched by the given criteria in the database
420
		 *
421
		 * @see mshop/locale/manager/currency/count/ansi
422
		 */
423
424
		/** mshop/locale/manager/currency/count/ansi
425
		 * Counts the number of records matched by the given criteria in the database
426
		 *
427
		 * Counts all records matched by the given criteria from the attribute
428
		 * database. The records must be from one of the sites that are
429
		 * configured via the context item. If the current site is part of
430
		 * a tree of sites, the statement can count all records from the
431
		 * current site and the complete sub-tree of sites.
432
		 *
433
		 * As the records can normally be limited by criteria from sub-managers,
434
		 * their tables must be joined in the SQL context. This is done by
435
		 * using the "internaldeps" property from the definition of the ID
436
		 * column of the sub-managers. These internal dependencies specify
437
		 * the JOIN between the tables and the used columns for joining. The
438
		 * ":joins" placeholder is then replaced by the JOIN strings from
439
		 * the sub-managers.
440
		 *
441
		 * To limit the records matched, conditions can be added to the given
442
		 * criteria object. It can contain comparisons like column names that
443
		 * must match specific values which can be combined by AND, OR or NOT
444
		 * operators. The resulting string of SQL conditions replaces the
445
		 * ":cond" placeholder before the statement is sent to the database
446
		 * server.
447
		 *
448
		 * Both, the strings for ":joins" and for ":cond" are the same as for
449
		 * the "search" SQL statement.
450
		 *
451
		 * Contrary to the "search" statement, it doesn't return any records
452
		 * but instead the number of records that have been found. As counting
453
		 * thousands of records can be a long running task, the maximum number
454
		 * of counted records is limited for performance reasons.
455
		 *
456
		 * The SQL statement should conform to the ANSI standard to be
457
		 * compatible with most relational database systems. This also
458
		 * includes using double quotes for table and column names.
459
		 *
460
		 * @param string SQL statement for counting items
461
		 * @since 2014.03
462
		 * @category Developer
463
		 * @see mshop/locale/manager/currency/insert/ansi
464
		 * @see mshop/locale/manager/currency/update/ansi
465
		 * @see mshop/locale/manager/currency/delete/ansi
466
		 * @see mshop/locale/manager/currency/search/ansi
467
		 */
468
		$cfgPathCount = 'mshop/locale/manager/currency/count';
469
470
		$results = $this->searchItemsBase( $conn, $search, $cfgPathSearch, $cfgPathCount, $required, $total );
471
472
		while( ( $row = $results->fetch() ) !== null )
473
		{
474
			if( $item = $this->applyFilter( $this->createItemBase( $row ) ) ) {
475
				$items[$row['locale.currency.id']] = $item;
476
			}
477
		}
478
479
		return map( $items );
480
	}
481
482
483
	/**
484
	 * Returns a new sub manager of the given type and name.
485
	 *
486
	 * @param string $manager Name of the sub manager type in lower case
487
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
488
	 * @return \Aimeos\MShop\Common\Manager\Iface manager
489
	 */
490
	public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
491
	{
492
		/** mshop/locale/manager/currency/name
493
		 * Class name of the used locale currency manager implementation
494
		 *
495
		 * Each default locale currency manager can be replaced by an alternative imlementation.
496
		 * To use this implementation, you have to set the last part of the class
497
		 * name as configuration value so the manager factory knows which class it
498
		 * has to instantiate.
499
		 *
500
		 * For example, if the name of the default class is
501
		 *
502
		 *  \Aimeos\MShop\Locale\Manager\Currency\Standard
503
		 *
504
		 * and you want to replace it with your own version named
505
		 *
506
		 *  \Aimeos\MShop\Locale\Manager\Currency\Mycurrency
507
		 *
508
		 * then you have to set the this configuration option:
509
		 *
510
		 *  mshop/locale/manager/currency/name = Mycurrency
511
		 *
512
		 * The value is the last part of your own class name and it's case sensitive,
513
		 * so take care that the configuration value is exactly named like the last
514
		 * part of the class name.
515
		 *
516
		 * The allowed characters of the class name are A-Z, a-z and 0-9. No other
517
		 * characters are possible! You should always start the last part of the class
518
		 * name with an upper case character and continue only with lower case characters
519
		 * or numbers. Avoid chamel case names like "MyCurrency"!
520
		 *
521
		 * @param string Last part of the class name
522
		 * @since 2014.03
523
		 * @category Developer
524
		 */
525
526
		/** mshop/locale/manager/currency/decorators/excludes
527
		 * Excludes decorators added by the "common" option from the locale currency manager
528
		 *
529
		 * Decorators extend the functionality of a class by adding new aspects
530
		 * (e.g. log what is currently done), executing the methods of the underlying
531
		 * class only in certain conditions (e.g. only for logged in users) or
532
		 * modify what is returned to the caller.
533
		 *
534
		 * This option allows you to remove a decorator added via
535
		 * "mshop/common/manager/decorators/default" before they are wrapped
536
		 * around the locale currency manager.
537
		 *
538
		 *  mshop/locale/manager/currency/decorators/excludes = array( 'decorator1' )
539
		 *
540
		 * This would remove the decorator named "decorator1" from the list of
541
		 * common decorators ("\Aimeos\MShop\Common\Manager\Decorator\*") added via
542
		 * "mshop/common/manager/decorators/default" for the locale currency manager.
543
		 *
544
		 * @param array List of decorator names
545
		 * @since 2014.03
546
		 * @category Developer
547
		 * @see mshop/common/manager/decorators/default
548
		 * @see mshop/locale/manager/currency/decorators/global
549
		 * @see mshop/locale/manager/currency/decorators/local
550
		 */
551
552
		/** mshop/locale/manager/currency/decorators/global
553
		 * Adds a list of globally available decorators only to the locale currency manager
554
		 *
555
		 * Decorators extend the functionality of a class by adding new aspects
556
		 * (e.g. log what is currently done), executing the methods of the underlying
557
		 * class only in certain conditions (e.g. only for logged in users) or
558
		 * modify what is returned to the caller.
559
		 *
560
		 * This option allows you to wrap global decorators
561
		 * ("\Aimeos\MShop\Common\Manager\Decorator\*") around the locale currency
562
		 * manager.
563
		 *
564
		 *  mshop/locale/manager/currency/decorators/global = array( 'decorator1' )
565
		 *
566
		 * This would add the decorator named "decorator1" defined by
567
		 * "\Aimeos\MShop\Common\Manager\Decorator\Decorator1" only to the locale
568
		 * currency manager.
569
		 *
570
		 * @param array List of decorator names
571
		 * @since 2014.03
572
		 * @category Developer
573
		 * @see mshop/common/manager/decorators/default
574
		 * @see mshop/locale/manager/currency/decorators/excludes
575
		 * @see mshop/locale/manager/currency/decorators/local
576
		 */
577
578
		/** mshop/locale/manager/currency/decorators/local
579
		 * Adds a list of local decorators only to the locale currency manager
580
		 *
581
		 * Decorators extend the functionality of a class by adding new aspects
582
		 * (e.g. log what is currently done), executing the methods of the underlying
583
		 * class only in certain conditions (e.g. only for logged in users) or
584
		 * modify what is returned to the caller.
585
		 *
586
		 * This option allows you to wrap local decorators
587
		 * ("\Aimeos\MShop\Locale\Manager\Currency\Decorator\*") around the locale
588
		 * currency manager.
589
		 *
590
		 *  mshop/locale/manager/currency/decorators/local = array( 'decorator2' )
591
		 *
592
		 * This would add the decorator named "decorator2" defined by
593
		 * "\Aimeos\MShop\Locale\Manager\Currency\Decorator\Decorator2" only to the
594
		 * locale currency manager.
595
		 *
596
		 * @param array List of decorator names
597
		 * @since 2014.03
598
		 * @category Developer
599
		 * @see mshop/common/manager/decorators/default
600
		 * @see mshop/locale/manager/currency/decorators/excludes
601
		 * @see mshop/locale/manager/currency/decorators/global
602
		 */
603
604
		return $this->getSubManagerBase( 'locale', 'currency/' . $manager, $name );
605
	}
606
607
608
	/**
609
	 * Returns the item specified by its code and domain/type if necessary
610
	 *
611
	 * @param string $code Code of the item
612
	 * @param string[] $ref List of domains to fetch list items and referenced items for
613
	 * @param string|null $domain Domain of the item if necessary to identify the item uniquely
614
	 * @param string|null $type Type code of the item if necessary to identify the item uniquely
615
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
616
	 * @return \Aimeos\MShop\Common\Item\Iface Item object
617
	 */
618
	public function find( string $code, array $ref = [], string $domain = null, string $type = null,
619
		?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
620
	{
621
		return $this->findBase( array( 'locale.currency.id' => $code ), $ref, $default );
622
	}
623
624
625
	/**
626
	 * Creates a filter object.
627
	 *
628
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
629
	 * @param bool $site TRUE for adding site criteria to limit items by the site of related items
630
	 * @return \Aimeos\Base\Criteria\Iface Returns the filter object
631
	 */
632
	public function filter( ?bool $default = false, bool $site = false ) : \Aimeos\Base\Criteria\Iface
633
	{
634
		return $this->filterBase( 'locale.currency', $default );
635
	}
636
637
638
	/**
639
	 * Create new item object initialized with given parameters.
640
	 *
641
	 * @param array $data Associative list of item key/value pairs
642
	 * @return \Aimeos\MShop\Locale\Item\Currency\Iface Currency item object
643
	 */
644
	protected function createItemBase( array $data = [] ) : \Aimeos\MShop\Locale\Item\Currency\Iface
645
	{
646
		return new \Aimeos\MShop\Locale\Item\Currency\Standard( $data );
647
	}
648
649
650
	/**
651
	 * Returns the site coditions for the search request
652
	 *
653
	 * @param string[] $keys Sorted list of criteria keys
654
	 * @param \Aimeos\Base\Criteria\Attribute\Iface[] $attributes Associative list of search keys and criteria attribute items as values
655
	 * @param int $sitelevel Site level constant from \Aimeos\MShop\Locale\Manager\Base
656
	 * @return \Aimeos\Base\Criteria\Expression\Iface[] List of search conditions
657
	 */
658
	protected function getSiteConditions( array $keys, array $attributes, int $sitelevel ) : array
659
	{
660
		return [];
661
	}
662
}
663