Completed
Push — master ( e3d84b...534c86 )
by Aimeos
02:08
created

Laravel::cleanup()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2018
6
 * @package MShop
7
 * @subpackage Customer
8
 */
9
10
11
namespace Aimeos\MShop\Customer\Manager\Property;
12
13
14
/**
15
 * Default property manager implementation.
16
 *
17
 * @package MShop
18
 * @subpackage Customer
19
 */
20
class Laravel
21
	extends \Aimeos\MShop\Customer\Manager\Property\Standard
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
22
{
23
	private $searchConfig = array(
0 ignored issues
show
Comprehensibility introduced by
Consider using a different property name as you override a private property of the parent class.
Loading history...
24
		'customer.property.id' => array(
25
			'code' => 'customer.property.id',
26
			'internalcode' => 'lvupr."id"',
27
			'internaldeps'=>array( 'LEFT JOIN "users_property" AS lvupr ON ( lvupr."parentid" = fos."id" )' ),
28
			'label' => 'Property ID',
29
			'type' => 'integer',
30
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
31
			'public' => false,
32
		),
33
		'customer.property.parentid' => array(
34
			'code' => 'customer.property.parentid',
35
			'internalcode' => 'lvupr."parentid"',
36
			'label' => 'Property parent ID',
37
			'type' => 'integer',
38
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
39
			'public' => false,
40
		),
41
		'customer.property.siteid' => array(
42
			'code' => 'customer.property.siteid',
43
			'internalcode' => 'lvupr."siteid"',
44
			'label' => 'Property site ID',
45
			'type' => 'integer',
46
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
47
			'public' => false,
48
		),
49
		'customer.property.typeid' => array(
50
			'code' => 'customer.property.typeid',
51
			'internalcode' => 'lvupr."typeid"',
52
			'label' => 'Property type ID',
53
			'type' => 'integer',
54
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_INT,
55
			'public' => false,
56
		),
57
		'customer.property.value' => array(
58
			'code' => 'customer.property.value',
59
			'internalcode' => 'lvupr."value"',
60
			'label' => 'Property value',
61
			'type' => 'string',
62
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
63
		),
64
		'customer.property.languageid' => array(
65
			'code' => 'customer.property.languageid',
66
			'internalcode' => 'lvupr."langid"',
67
			'label' => 'Property language ID',
68
			'type' => 'string',
69
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
70
		),
71
		'customer.property.ctime' => array(
72
			'code' => 'customer.property.ctime',
73
			'internalcode' => 'lvupr."ctime"',
74
			'label' => 'Property create date/time',
75
			'type' => 'datetime',
76
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
77
			'public' => false,
78
		),
79
		'customer.property.mtime' => array(
80
			'code' => 'customer.property.mtime',
81
			'internalcode' => 'lvupr."mtime"',
82
			'label' => 'Property modify date',
83
			'type' => 'datetime',
84
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
85
			'public' => false,
86
		),
87
		'customer.property.editor' => array(
88
			'code' => 'customer.property.editor',
89
			'internalcode' => 'lvupr."editor"',
90
			'label' => 'Property editor',
91
			'type' => 'string',
92
			'internaltype' => \Aimeos\MW\DB\Statement\Base::PARAM_STR,
93
			'public' => false,
94
		),
95
	);
96
97
98
	/**
99
	 * Removes old entries from the storage.
100
	 *
101
	 * @param integer[] $siteids List of IDs for sites whose entries should be deleted
102
	 */
103 View Code Duplication
	public function cleanup( array $siteids )
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
104
	{
105
		$path = 'mshop/customer/manager/property/submanagers';
106
		foreach( $this->getContext()->getConfig()->get( $path, [] ) as $domain ) {
107
			$this->getObject()->getSubManager( $domain )->cleanup( $siteids );
108
		}
109
110
		$this->cleanupBase( $siteids, 'mshop/customer/manager/property/laravel/delete' );
111
	}
112
113
114
	/**
115
	 * Returns the attributes that can be used for searching.
116
	 *
117
	 * @param boolean $withsub Return also attributes of sub-managers if true
118
	 * @return array Returns a list of attribtes implementing \Aimeos\MW\Criteria\Attribute\Iface
119
	 */
120
	public function getSearchAttributes( $withsub = true )
121
	{
122
		$path = 'mshop/customer/manager/property/submanagers';
123
124
		return $this->getSearchAttributesBase( $this->searchConfig, $path, ['type'], $withsub );
125
	}
126
127
128
	/**
129
	 * Returns a new manager for customer extensions
130
	 *
131
	 * @param string $manager Name of the sub manager type in lower case
132
	 * @param string|null $name Name of the implementation, will be from
133
	 * configuration (or Default) if null
134
	 * @return \Aimeos\MShop\Common\Manager\Iface Manager for different extensions, e.g property types, property lists etc.
135
	 */
136
	public function getSubManager( $manager, $name = null )
137
	{
138
		return $this->getSubManagerBase( 'customer', 'property/' . $manager, ( $name === null ? 'Laravel' : $name ) );
139
	}
140
141
142
	/**
143
	 * Returns the config path for retrieving the configuration values.
144
	 *
145
	 * @return string Configuration path
146
	 */
147
	protected function getConfigPath()
148
	{
149
		return 'mshop/customer/manager/property/laravel/';
150
	}
151
152
153
	/**
154
	 * Returns the search configuration for searching items.
155
	 *
156
	 * @return array Associative list of search keys and search definitions
157
	 */
158
	protected function getSearchConfig()
159
	{
160
		return $this->searchConfig;
161
	}
162
}
163