|
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
|
|
|
|