Passed
Push — master ( c46287...9f1c00 )
by Aimeos
05:19
created

Standard::prefix()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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