Passed
Push — master ( 7b7538...994c79 )
by Aimeos
05:04
created

Standard::getSaveAttributes()   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 Group
8
 */
9
10
11
namespace Aimeos\MShop\Group\Manager;
12
13
14
/**
15
 * Default implementation of the group manager
16
 *
17
 * @package MShop
18
 * @subpackage Group
19
 */
20
class Standard
21
	extends \Aimeos\MShop\Common\Manager\Base
22
	implements \Aimeos\MShop\Group\Manager\Iface, \Aimeos\MShop\Common\Manager\Factory\Iface
23
{
24
	private array $searchConfig = [
25
		'code' => [
26
			'code' => 'group.code',
27
			'internalcode' => 'mgro."code"',
28
			'label' => 'Group code',
29
		],
30
		'label' => [
31
			'code' => 'group.label',
32
			'internalcode' => 'mgro."label"',
33
			'label' => 'Group label',
34
		],
35
	];
36
37
38
	/**
39
	 * Creates a new empty item instance
40
	 *
41
	 * @param array $values Values the item should be initialized with
42
	 * @return \Aimeos\MShop\Group\Item\Iface New group item object
43
	 */
44
	public function create( array $values = [] ) : \Aimeos\MShop\Common\Item\Iface
45
	{
46
		$values['group.siteid'] = $values['group.siteid'] ?? $this->context()->locale()->getSiteId();
47
		return new \Aimeos\MShop\Group\Item\Standard( 'group.', $values );
48
	}
49
50
51
	/**
52
	 * Returns the additional column/search definitions
53
	 *
54
	 * @return array Associative list of column names as keys and items implementing \Aimeos\Base\Criteria\Attribute\Iface
55
	 */
56
	public function getSaveAttributes() : array
57
	{
58
		return $this->createAttributes( $this->searchConfig );
59
	}
60
61
62
	/**
63
	 * Returns the item specified by its code and domain/type if necessary
64
	 *
65
	 * @param string $code Code of the item
66
	 * @param string[] $ref List of domains to fetch list items and referenced items for
67
	 * @param string|null $domain Domain of the item if necessary to identify the item uniquely
68
	 * @param string|null $type Type code of the item if necessary to identify the item uniquely
69
	 * @param bool|null $default Add default criteria or NULL for relaxed default criteria
70
	 * @return \Aimeos\MShop\Common\Item\Iface Item object
71
	 */
72
	public function find( string $code, array $ref = [], string $domain = null, string $type = null,
73
		?bool $default = false ) : \Aimeos\MShop\Common\Item\Iface
74
	{
75
		return $this->findBase( ['group.code' => $code], $ref, $default );
76
	}
77
78
79
	/**
80
	 * Returns the prefix for the item properties and search keys.
81
	 *
82
	 * @return string Prefix for the item properties and search keys
83
	 */
84
	protected function getPrefix() : string
85
	{
86
		return 'group.';
87
	}
88
}
89