Passed
Push — master ( eade66...a4d1b5 )
by Aimeos
03:55
created

FosUser::getSubManager()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 2
nc 1
nop 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2015-2020
6
 * @package MShop
7
 * @subpackage Customer
8
 */
9
10
11
namespace Aimeos\MShop\Customer\Manager\Lists\Type;
12
13
14
/**
15
 * Fos user bundle implementation of the customer list type class.
16
 *
17
 * @package MShop
18
 * @subpackage Customer
19
 */
20
class FosUser
21
	extends \Aimeos\MShop\Customer\Manager\Lists\Type\Standard
22
{
23
	private $searchConfig = array(
24
		'customer.lists.type.id' => array(
25
			'code' => 'customer.lists.type.id',
26
			'internalcode' => 'foslity."id"',
27
			'label' => 'Customer list type ID',
28
			'type'=> 'integer',
29
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
30
			'public' => false,
31
		),
32
		'customer.lists.type.siteid' => array(
33
			'code' => 'customer.lists.type.siteid',
34
			'internalcode' => 'foslity."siteid"',
35
			'label' => 'Customer list type site ID',
36
			'type' => 'string',
37
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
38
			'public' => false,
39
		),
40
		'customer.lists.type.code' => array(
41
			'code' => 'customer.lists.type.code',
42
			'internalcode' => 'foslity."code"',
43
			'label' => 'Customer list type code',
44
			'type'=> 'string',
45
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
46
		),
47
		'customer.lists.type.domain' => array(
48
			'code' => 'customer.lists.type.domain',
49
			'internalcode' => 'foslity."domain"',
50
			'label' => 'Customer list type domain',
51
			'type'=> 'string',
52
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
53
		),
54
		'customer.lists.type.label' => array(
55
			'code' => 'customer.lists.type.label',
56
			'internalcode' => 'foslity."label"',
57
			'label' => 'Customer list type label',
58
			'type'=> 'string',
59
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
60
		),
61
		'customer.lists.type.status' => array(
62
			'code' => 'customer.lists.type.status',
63
			'internalcode' => 'foslity."status"',
64
			'label' => 'Customer list type status',
65
			'type'=> 'integer',
66
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
67
		),
68
		'customer.lists.type.position' => array(
69
			'code' => 'customer.lists.type.position',
70
			'internalcode' => 'foslity."pos"',
71
			'label' => 'Customer list type position',
72
			'type'=> 'integer',
73
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
74
		),
75
		'customer.lists.type.ctime'=> array(
76
			'code' => 'customer.lists.type.ctime',
77
			'internalcode' => 'foslity."ctime"',
78
			'label' => 'Customer list type create date/time',
79
			'type'=> 'datetime',
80
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
81
		),
82
		'customer.lists.type.mtime'=> array(
83
			'code' => 'customer.lists.type.mtime',
84
			'internalcode' => 'foslity."mtime"',
85
			'label' => 'Customer list type modification date/time',
86
			'type'=> 'datetime',
87
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
88
		),
89
		'customer.lists.type.editor'=> array(
90
			'code' => 'customer.lists.type.editor',
91
			'internalcode' => 'foslity."editor"',
92
			'label' => 'Customer list type editor',
93
			'type'=> 'string',
94
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
95
		),
96
	);
97
98
99
	/**
100
	 * Removes old entries from the storage.
101
	 *
102
	 * @param string[] $siteids List of IDs for sites whose entries should be deleted
103
	 * @return \Aimeos\MShop\Common\Manager\Iface Same object for fluent interface
104
	 */
105
	public function clear( array $siteids ) : \Aimeos\MShop\Common\Manager\Iface
106
	{
107
		$path = 'mshop/customer/manager/lists/type/submanagers';
108
		foreach( $this->getContext()->getConfig()->get( $path, [] ) as $domain ) {
109
			$this->getObject()->getSubManager( $domain )->clear( $siteids );
110
		}
111
112
		return $this->clearBase( $siteids, 'mshop/customer/manager/lists/type/fosuser/delete' );
113
	}
114
115
116
	/**
117
	 * Returns the list attributes that can be used for searching.
118
	 *
119
	 * @param bool $withsub Return also attributes of sub-managers if true
120
	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
121
	 */
122
	public function getSearchAttributes( bool $withsub = true ) : array
123
	{
124
		$path = 'mshop/customer/manager/lists/type/submanagers';
125
126
		return $this->getSearchAttributesBase( $this->searchConfig, $path, [], $withsub );
127
	}
128
129
130
	/**
131
	 * Returns a new manager for customer extensions
132
	 *
133
	 * @param string $manager Name of the sub manager type in lower case
134
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
135
	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
136
	 */
137
	public function getSubManager( string $manager, string $name = null ) : \Aimeos\MShop\Common\Manager\Iface
138
	{
139
		return $this->getSubManagerBase( 'customer', 'lists/type/' . $manager, ( $name === null ? 'FosUser' : $name ) );
140
	}
141
142
143
	/**
144
	 * Returns the config path for retrieving the configuration values.
145
	 *
146
	 * @return string Configuration path (mshop/customer/manager/lists/type/fosuser/)
147
	 */
148
	protected function getConfigPath() : string
149
	{
150
		return 'mshop/customer/manager/lists/type/fosuser/';
151
	}
152
153
154
	/**
155
	 * Returns the search configuration for searching items.
156
	 *
157
	 * @return array Associative list of search keys and search definitions
158
	 */
159
	protected function getSearchConfig() : array
160
	{
161
		return $this->searchConfig;
162
	}
163
}
164