1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @license LGPLv3, http://opensource.org/licenses/LGPL-3.0 |
5
|
|
|
* @copyright Aimeos (aimeos.org), 2017-2018 |
6
|
|
|
* @package Controller |
7
|
|
|
* @subpackage Frontend |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
|
11
|
|
|
namespace Aimeos\Controller\Frontend\Attribute\Decorator; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* Base for attribute frontend controller decorators |
16
|
|
|
* |
17
|
|
|
* @package Controller |
18
|
|
|
* @subpackage Frontend |
19
|
|
|
*/ |
20
|
|
|
abstract class Base |
21
|
|
|
extends \Aimeos\Controller\Frontend\Base |
22
|
|
|
implements \Aimeos\Controller\Frontend\Common\Decorator\Iface, \Aimeos\Controller\Frontend\Attribute\Iface |
23
|
|
|
{ |
24
|
|
|
private $controller; |
25
|
|
|
|
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* Initializes the controller decorator. |
29
|
|
|
* |
30
|
|
|
* @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
31
|
|
|
* @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
32
|
|
|
*/ |
33
|
|
|
public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
34
|
|
|
{ |
35
|
|
|
$iface = \Aimeos\Controller\Frontend\Attribute\Iface::class; |
36
|
|
|
$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller ); |
|
|
|
|
37
|
|
|
|
38
|
|
|
parent::__construct( $context ); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Passes unknown methods to wrapped objects. |
44
|
|
|
* |
45
|
|
|
* @param string $name Name of the method |
46
|
|
|
* @param array $param List of method parameter |
47
|
|
|
* @return mixed Returns the value of the called method |
48
|
|
|
* @throws \Aimeos\Controller\Frontend\Exception If method call failed |
49
|
|
|
*/ |
50
|
|
|
public function __call( $name, array $param ) |
51
|
|
|
{ |
52
|
|
|
return @call_user_func_array( array( $this->controller, $name ), $param ); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Clones objects in controller and resets values |
58
|
|
|
*/ |
59
|
|
|
public function __clone() |
60
|
|
|
{ |
61
|
|
|
$this->controller = clone $this->controller; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Adds attribute IDs for filtering |
67
|
|
|
* |
68
|
|
|
* @param array|string $attrIds Attribute ID or list of IDs |
69
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
70
|
|
|
* @since 2019.04 |
71
|
|
|
*/ |
72
|
|
|
public function attribute( $attrIds ) |
73
|
|
|
{ |
74
|
|
|
$this->controller->attribute( $attrIds ); |
75
|
|
|
return $this; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
|
79
|
|
|
/** |
80
|
|
|
* Adds generic condition for filtering attributes |
81
|
|
|
* |
82
|
|
|
* @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~=" |
83
|
|
|
* @param string $key Search key defined by the attribute manager, e.g. "attribute.status" |
84
|
|
|
* @param array|string $value Value or list of values to compare to |
85
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
86
|
|
|
* @since 2019.04 |
87
|
|
|
*/ |
88
|
|
|
public function compare( $operator, $key, $value ) |
89
|
|
|
{ |
90
|
|
|
$this->controller->compare( $operator, $key, $value ); |
91
|
|
|
return $this; |
92
|
|
|
} |
93
|
|
|
|
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Adds the domain of the attributes for filtering |
97
|
|
|
* |
98
|
|
|
* @param string $domain Domain of the attributes |
99
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
100
|
|
|
* @since 2019.04 |
101
|
|
|
*/ |
102
|
|
|
public function domain( $domain ) |
103
|
|
|
{ |
104
|
|
|
$this->controller->domain( $domain ); |
105
|
|
|
return $this; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
|
109
|
|
|
/** |
110
|
|
|
* Returns the attribute for the given attribute ID |
111
|
|
|
* |
112
|
|
|
* @param string $id Unique attribute ID |
113
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
114
|
|
|
* @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
115
|
|
|
* @since 2019.04 |
116
|
|
|
*/ |
117
|
|
|
public function get( $id, $domains = ['media', 'price', 'text'] ) |
118
|
|
|
{ |
119
|
|
|
return $this->controller->get( $id, $domains ); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
|
123
|
|
|
/** |
124
|
|
|
* Returns the attribute for the given attribute code |
125
|
|
|
* |
126
|
|
|
* @param string $code Unique attribute code |
127
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
128
|
|
|
* @param string $type Type assigned to the attribute |
129
|
|
|
* @return \Aimeos\MShop\Attribute\Item\Iface Attribute item including the referenced domains items |
130
|
|
|
* @since 2019.04 |
131
|
|
|
*/ |
132
|
|
|
public function find( $code, $domains = ['media', 'price', 'text'], $type ) |
133
|
|
|
{ |
134
|
|
|
return $this->controller->find( $code, $domains, $type ); |
135
|
|
|
} |
136
|
|
|
|
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Parses the given array and adds the conditions to the list of conditions |
140
|
|
|
* |
141
|
|
|
* @param array $conditions List of conditions, e.g. ['&&' => [['>' => ['attribute.status' => 0]], ['==' => ['attribute.type' => 'color']]]] |
142
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
143
|
|
|
* @since 2019.04 |
144
|
|
|
*/ |
145
|
|
|
public function parse( array $conditions ) |
146
|
|
|
{ |
147
|
|
|
$this->controller->parse( $conditions ); |
148
|
|
|
return $this; |
149
|
|
|
} |
150
|
|
|
|
151
|
|
|
|
152
|
|
|
/** |
153
|
|
|
* Returns the attributes filtered by the previously assigned conditions |
154
|
|
|
* |
155
|
|
|
* @param string[] $domains Domain names of items that are associated with the attributes and that should be fetched too |
156
|
|
|
* @param integer &$total Parameter where the total number of found attributes will be stored in |
157
|
|
|
* @return \Aimeos\MShop\Attribute\Item\Iface[] Ordered list of attribute items |
158
|
|
|
* @since 2019.04 |
159
|
|
|
*/ |
160
|
|
|
public function search( $domains = ['media', 'price', 'text'], &$total = null ) |
161
|
|
|
{ |
162
|
|
|
return $this->controller->search( $domains, $total ); |
163
|
|
|
} |
164
|
|
|
|
165
|
|
|
|
166
|
|
|
/** |
167
|
|
|
* Sets the start value and the number of returned attributes for slicing the list of found attributes |
168
|
|
|
* |
169
|
|
|
* @param integer $start Start value of the first attribute in the list |
170
|
|
|
* @param integer $limit Number of returned attributes |
171
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
172
|
|
|
* @since 2019.04 |
173
|
|
|
*/ |
174
|
|
|
public function slice( $start, $limit ) |
175
|
|
|
{ |
176
|
|
|
$this->controller->slice( $start, $limit ); |
177
|
|
|
return $this; |
178
|
|
|
} |
179
|
|
|
|
180
|
|
|
|
181
|
|
|
/** |
182
|
|
|
* Sets the sorting of the attribute list |
183
|
|
|
* |
184
|
|
|
* @param string|null $key Sorting of the attribute list like "position" or "-position", null for no sortation |
185
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
186
|
|
|
* @since 2019.04 |
187
|
|
|
*/ |
188
|
|
|
public function sort( $key = null ) |
189
|
|
|
{ |
190
|
|
|
$this->controller->sort( $key ); |
191
|
|
|
return $this; |
192
|
|
|
} |
193
|
|
|
|
194
|
|
|
|
195
|
|
|
/** |
196
|
|
|
* Adds attribute types for filtering |
197
|
|
|
* |
198
|
|
|
* @param array|string $codes Attribute ID or list of IDs |
199
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Attribute controller for fluent interface |
200
|
|
|
* @since 2019.04 |
201
|
|
|
*/ |
202
|
|
|
public function type( $codes ) |
203
|
|
|
{ |
204
|
|
|
$this->controller->type( $codes ); |
205
|
|
|
return $this; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
|
|
209
|
|
|
/** |
210
|
|
|
* Returns the frontend controller |
211
|
|
|
* |
212
|
|
|
* @return \Aimeos\Controller\Frontend\Attribute\Iface Frontend controller object |
213
|
|
|
*/ |
214
|
|
|
protected function getController() |
215
|
|
|
{ |
216
|
|
|
return $this->controller; |
217
|
|
|
} |
218
|
|
|
} |
219
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.