Completed
Push — master ( 74531e...29a45b )
by Aimeos
02:46
created

Typo3   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 180
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 8
c 2
b 0
f 0
lcom 1
cbo 0
dl 0
loc 180
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubManager() 0 4 2
A getSearchAttributes() 0 6 1
A saveItem() 0 13 3
A getConfigPath() 0 4 1
A getSearchConfig() 0 4 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Metaways Infosystems GmbH, 2013
6
 * @copyright Aimeos (aimeos.org), 2014
7
 * @package MShop
8
 * @subpackage Customer
9
 */
10
11
12
namespace Aimeos\MShop\Customer\Manager\Lists;
13
14
15
/**
16
 * TYPO3 implementation of the customer list class.
17
 *
18
 * @package MShop
19
 * @subpackage Customer
20
 */
21
class Typo3
22
	extends \Aimeos\MShop\Customer\Manager\Lists\Standard
23
	implements \Aimeos\MShop\Customer\Manager\Lists\Iface, \Aimeos\MShop\Common\Manager\Lists\Iface
24
{
25
	private $searchConfig = array(
26
		'customer.lists.id'=> array(
27
			'code'=>'customer.lists.id',
28
			'internalcode'=>'t3feuli."id"',
29
			'internaldeps' => array( 'LEFT JOIN "fe_users_list" AS t3feuli ON ( t3feu."uid" = t3feuli."parentid" )' ),
30
			'label'=>'Customer list ID',
31
			'type'=> 'integer',
32
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT,
33
			'public' => false,
34
		),
35
		'customer.lists.siteid'=> array(
36
			'code'=>'customer.lists.siteid',
37
			'internalcode'=>'t3feuli."siteid"',
38
			'label'=>'Customer list site ID',
39
			'type'=> 'integer',
40
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT,
41
			'public' => false,
42
		),
43
		'customer.lists.parentid'=> array(
44
			'code'=>'customer.lists.parentid',
45
			'internalcode'=>'t3feuli."parentid"',
46
			'label'=>'Customer list parent ID',
47
			'type'=> 'integer',
48
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_INT,
49
			'public' => false,
50
		),
51
		'customer.lists.domain'=> array(
52
			'code'=>'customer.lists.domain',
53
			'internalcode'=>'t3feuli."domain"',
54
			'label'=>'Customer list domain',
55
			'type'=> 'string',
56
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
57
		),
58
		'customer.lists.typeid' => array(
59
			'code'=>'customer.lists.typeid',
60
			'internalcode'=>'t3feuli."typeid"',
61
			'label'=>'Customer list type ID',
62
			'type'=> 'integer',
63
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
64
			'public' => false,
65
		),
66
		'customer.lists.refid'=> array(
67
			'code'=>'customer.lists.refid',
68
			'internalcode'=>'t3feuli."refid"',
69
			'label'=>'Customer list reference ID',
70
			'type'=> 'string',
71
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
72
		),
73
		'customer.lists.datestart' => array(
74
			'code'=>'customer.lists.datestart',
75
			'internalcode'=>'t3feuli."start"',
76
			'label'=>'Customer list start date/time',
77
			'type'=> 'datetime',
78
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
79
		),
80
		'customer.lists.dateend' => array(
81
			'code'=>'customer.lists.dateend',
82
			'internalcode'=>'t3feuli."end"',
83
			'label'=>'Customer list end date/time',
84
			'type'=> 'datetime',
85
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
86
		),
87
		'customer.lists.config' => array(
88
			'code'=>'customer.lists.config',
89
			'internalcode'=>'t3feuli."config"',
90
			'label'=>'Customer list position',
91
			'type'=> 'string',
92
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
93
		),
94
		'customer.lists.position' => array(
95
			'code'=>'customer.lists.position',
96
			'internalcode'=>'t3feuli."pos"',
97
			'label'=>'Customer list position',
98
			'type'=> 'integer',
99
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
100
		),
101
		'customer.lists.status' => array(
102
			'code'=>'customer.lists.status',
103
			'internalcode'=>'t3feuli."status"',
104
			'label'=>'Customer list status',
105
			'type'=> 'integer',
106
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
107
		),
108
		'customer.lists.ctime'=> array(
109
			'code'=>'customer.lists.ctime',
110
			'internalcode'=>'t3feuli."ctime"',
111
			'label'=>'Customer list create date/time',
112
			'type'=> 'datetime',
113
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
114
		),
115
		'customer.lists.mtime'=> array(
116
			'code'=>'customer.lists.mtime',
117
			'internalcode'=>'t3feuli."mtime"',
118
			'label'=>'Customer list modification date/time',
119
			'type'=> 'datetime',
120
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
121
		),
122
		'customer.lists.editor'=> array(
123
			'code'=>'customer.lists.editor',
124
			'internalcode'=>'t3feuli."editor"',
125
			'label'=>'Customer list editor',
126
			'type'=> 'string',
127
			'internaltype'=> \Aimeos\MW\DB\Statement\Base::PARAM_STR,
128
		),
129
	);
130
131
132
	/**
133
	 * Returns the list attributes that can be used for searching.
134
	 *
135
	 * @param boolean $withsub Return also attributes of sub-managers if true
136
	 * @return array List of attribute items implementing \Aimeos\MW\Criteria\Attribute\Iface
137
	 */
138
	public function getSearchAttributes( $withsub = true )
139
	{
140
		$path = 'mshop/customer/manager/lists/submanagers';
141
142
		return $this->getSearchAttributesBase( $this->searchConfig, $path, array( 'type' ), $withsub );
143
	}
144
145
146
	/**
147
	 * Returns a new manager for customer extensions
148
	 *
149
	 * @param string $manager Name of the sub manager type in lower case
150
	 * @param string|null $name Name of the implementation, will be from configuration (or Default) if null
151
	 * @return mixed Manager for different extensions, e.g stock, tags, locations, etc.
152
	 */
153
	public function getSubManager( $manager, $name = null )
154
	{
155
		return $this->getSubManagerBase( 'customer', 'lists/' . $manager, ( $name === null ? 'Typo3' : $name ) );
156
	}
157
158
159
	/**
160
	 * Updates or adds a common list item object.
161
	 *
162
	 * @param \Aimeos\MShop\Common\Item\Lists\Iface $item List item object which should be saved
163
	 * @param boolean $fetch True if the new ID should be returned in the item
164
	 */
165
	public function saveItem( \Aimeos\MShop\Common\Item\Iface $item, $fetch = true )
166
	{
167
		$iface = '\\Aimeos\\MShop\\Common\\Item\\Lists\\Iface';
168
		if( !( $item instanceof $iface ) ) {
169
			throw new \Aimeos\MShop\Exception( sprintf( 'Object is not of required type "%1$s"', $iface ) );
170
		}
171
172
		if( $item->getDomain() === 'customer/group' ) {
173
			throw new \Aimeos\MShop\Customer\Exception( sprintf( 'Adding groups to customers is not supported, please use the TYPO3 backend' ) );
174
		}
175
176
		parent::saveItem( $item, $fetch );
177
	}
178
179
180
	/**
181
	 * Returns the config path for retrieving the configuration values.
182
	 *
183
	 * @return string Configuration path (mshop/customer/manager/lists/type/typo3/item/)
184
	 */
185
	protected function getConfigPath()
186
	{
187
		return 'mshop/customer/manager/lists/typo3/';
188
	}
189
190
191
	/**
192
	 * Returns the search configuration for searching items.
193
	 *
194
	 * @return array Associative list of search keys and search definitions
195
	 */
196
	protected function getSearchConfig()
197
	{
198
		return $this->searchConfig;
199
	}
200
}
201