Passed
Push — master ( b7775a...4e1b50 )
by Aimeos
03:15
created

Base::has()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 3
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2020
6
 * @package Controller
7
 * @subpackage Frontend
8
 */
9
10
11
namespace Aimeos\Controller\Frontend\Product\Decorator;
12
13
14
/**
15
 * Base for product 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\Product\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
		parent::__construct( $context );
36
37
		$iface = \Aimeos\Controller\Frontend\Product\Iface::class;
38
		$this->controller = \Aimeos\MW\Common\Base::checkClass( $iface, $controller );
39
	}
40
41
42
	/**
43
	 * Clones objects in decorator
44
	 */
45
	public function __clone()
46
	{
47
		$this->controller = clone $this->controller;
48
	}
49
50
51
	/**
52
	 * Passes unknown methods to wrapped objects.
53
	 *
54
	 * @param string $name Name of the method
55
	 * @param array $param List of method parameter
56
	 * @return mixed Returns the value of the called method
57
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
58
	 */
59
	public function __call( string $name, array $param )
60
	{
61
		return @call_user_func_array( array( $this->controller, $name ), $param );
62
	}
63
64
65
	/**
66
	 * Returns the aggregated count of products for the given key.
67
	 *
68
	 * @param string $key Search key to aggregate for, e.g. "index.attribute.id"
69
	 * @param string|null $value Search key for aggregating the value column
70
	 * @param string|null $type Type of the aggregation, empty string for count or "sum" or "avg" (average)
71
	 * @return \Aimeos\Map Associative list of key values as key and the product count for this key as value
72
	 * @since 2019.04
73
	 */
74
	public function aggregate( string $key, string $value = null, string $type = null ) : \Aimeos\Map
75
	{
76
		return $this->controller->aggregate( $key, $value, $type );
77
	}
78
79
80
	/**
81
	 * Adds attribute IDs for filtering where products must reference all IDs
82
	 *
83
	 * @param array|string $attrIds Attribute ID or list of IDs
84
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
85
	 * @since 2019.04
86
	 */
87
	public function allOf( $attrIds ) : \Aimeos\Controller\Frontend\Product\Iface
88
	{
89
		$this->controller->allOf( $attrIds );
90
		return $this;
91
	}
92
93
94
	/**
95
	 * Adds catalog IDs for filtering
96
	 *
97
	 * @param array|string $catIds Catalog ID or list of IDs
98
	 * @param string $listtype List type of the products referenced by the categories
99
	 * @param int $level Constant from \Aimeos\MW\Tree\Manager\Base if products in subcategories are matched too
100
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
101
	 * @since 2019.04
102
	 */
103
	public function category( $catIds, string $listtype = 'default', int $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE ) : \Aimeos\Controller\Frontend\Product\Iface
104
	{
105
		$this->controller->category( $catIds, $listtype, $level );
106
		return $this;
107
	}
108
109
110
	/**
111
	 * Adds generic condition for filtering products
112
	 *
113
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
114
	 * @param string $key Search key defined by the product manager, e.g. "product.status"
115
	 * @param array|string $value Value or list of values to compare to
116
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
117
	 * @since 2019.04
118
	 */
119
	public function compare( string $operator, string $key, $value ) : \Aimeos\Controller\Frontend\Product\Iface
120
	{
121
		$this->controller->compare( $operator, $key, $value );
122
		return $this;
123
	}
124
125
126
	/**
127
	 * Returns the product for the given product code
128
	 *
129
	 * @param string $code Unique product code
130
	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
131
	 * @since 2019.04
132
	 */
133
	public function find( string $code ) : \Aimeos\MShop\Product\Item\Iface
134
	{
135
		return $this->controller->find( $code );
136
	}
137
138
139
	/**
140
	 * Creates a search function string for the given name and parameters
141
	 *
142
	 * @param string $name Name of the search function without parenthesis, e.g. "product:has"
143
	 * @param array $params List of parameters for the search function with numeric keys starting at 0
144
	 * @return string Search function string that can be used in compare()
145
	 */
146
	public function function( string $name, array $params ) : string
147
	{
148
		return $this->controller->function( $name, $params );
149
	}
150
151
152
	/**
153
	 * Returns the product for the given product ID
154
	 *
155
	 * @param string $id Unique product ID
156
	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
157
	 * @since 2019.04
158
	 */
159
	public function get( string $id ) : \Aimeos\MShop\Product\Item\Iface
160
	{
161
		return $this->controller->get( $id );
162
	}
163
164
165
	/**
166
	 * Adds a filter to return only items containing a reference to the given ID
167
	 *
168
	 * @param string $domain Domain name of the referenced item, e.g. "attribute"
169
	 * @param string|null $type Type code of the reference, e.g. "variant" or null for all types
170
	 * @param string|null $refId ID of the referenced item of the given domain or null for all references
171
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
172
	 * @since 2019.04
173
	 */
174
	public function has( string $domain, string $type = null, string $refId = null ) : \Aimeos\Controller\Frontend\Product\Iface
175
	{
176
		$this->controller->has( $domain, $type, $refId );
177
		return $this;
178
	}
179
180
181
	/**
182
	 * Adds attribute IDs for filtering where products must reference at least one ID
183
	 *
184
	 * @param array|string $attrIds Attribute ID or list of IDs
185
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
186
	 * @since 2019.04
187
	 */
188
	public function oneOf( $attrIds ) : \Aimeos\Controller\Frontend\Product\Iface
189
	{
190
		$this->controller->oneOf( $attrIds );
191
		return $this;
192
	}
193
194
195
	/**
196
	 * Parses the given array and adds the conditions to the list of conditions
197
	 *
198
	 * @param array $conditions List of conditions, e.g. ['&&' => [['>' => ['product.status' => 0]], ['==' => ['product.type' => 'default']]]]
199
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
200
	 * @since 2019.04
201
	 */
202
	public function parse( array $conditions ) : \Aimeos\Controller\Frontend\Product\Iface
203
	{
204
		$this->controller->parse( $conditions );
205
		return $this;
206
	}
207
208
209
	/**
210
	 * Adds price restrictions for filtering
211
	 *
212
	 * @param array|string $value Upper price limit, list of lower and upper price or NULL for no restrictions
213
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
214
	 * @since 2020.10
215
	 */
216
	public function price( $value = null ) : \Aimeos\Controller\Frontend\Product\Iface
217
	{
218
		$this->controller->price( $value );
219
		return $this;
220
	}
221
222
223
	/**
224
	 * Adds product IDs for filtering
225
	 *
226
	 * @param array|string $prodIds Product ID or list of IDs
227
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
228
	 * @since 2019.04
229
	 */
230
	public function product( $prodIds ) : \Aimeos\Controller\Frontend\Product\Iface
231
	{
232
		$this->controller->product( $prodIds );
233
		return $this;
234
	}
235
236
237
	/**
238
	 * Adds a filter to return only items containing the property
239
	 *
240
	 * @param string $type Type code of the property, e.g. "isbn"
241
	 * @param string|null $value Exact value of the property
242
	 * @param string|null $langId ISO country code (en or en_US) or null if not language specific
243
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
244
	 * @since 2019.04
245
	 */
246
	public function property( string $type, string $value = null, string $langId = null ) : \Aimeos\Controller\Frontend\Product\Iface
247
	{
248
		$this->controller->property( $type, $value, $langId );
249
		return $this;
250
	}
251
252
253
	/**
254
	 * Returns the product for the given product URL name
255
	 *
256
	 * @param string $name Product URL name
257
	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
258
	 * @since 2019.04
259
	 */
260
	public function resolve( string $name ) : \Aimeos\MShop\Product\Item\Iface
261
	{
262
		return $this->controller->resolve( $name );
263
	}
264
265
266
	/**
267
	 * Returns the products filtered by the previously assigned conditions
268
	 *
269
	 * @param int &$total Parameter where the total number of found products will be stored in
270
	 * @return \Aimeos\Map Ordered list of items implementing \Aimeos\MShop\Product\Item\Iface
271
	 * @since 2019.04
272
	 */
273
	public function search( int &$total = null ) : \Aimeos\Map
274
	{
275
		return $this->controller->search( $total );
276
	}
277
278
279
	/**
280
	 * Sets the start value and the number of returned products for slicing the list of found products
281
	 *
282
	 * @param int $start Start value of the first product in the list
283
	 * @param int $limit Number of returned products
284
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
285
	 * @since 2019.04
286
	 */
287
	public function slice( int $start, int $limit ) : \Aimeos\Controller\Frontend\Product\Iface
288
	{
289
		$this->controller->slice( $start, $limit );
290
		return $this;
291
	}
292
293
294
	/**
295
	 * Sets the sorting of the result list
296
	 *
297
	 * @param string|null $key Sorting of the result list like "name", "-name", "price", "-price", "code", "-code", "ctime, "-ctime" and "relevance", null for no sorting
298
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
299
	 * @since 2019.04
300
	 */
301
	public function sort( string $key = null ) : \Aimeos\Controller\Frontend\Product\Iface
302
	{
303
		$this->controller->sort( $key );
304
		return $this;
305
	}
306
307
308
	/**
309
	 * Adds minimum stock level for filtering
310
	 *
311
	 * @param string|int|float|null Minimum stock level
0 ignored issues
show
Bug introduced by
The type Aimeos\Controller\Fronte...oduct\Decorator\Minimum was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
312
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
313
	 * @since 2021.01
314
	 */
315
	public function stock( $minvalue )
316
	{
317
		$this->controller->stock( $minvalue );
318
		return $this;
319
	}
320
321
322
	/**
323
	 * Adds supplier IDs for filtering
324
	 *
325
	 * @param array|string $supIds Supplier ID or list of IDs
326
	 * @param string $listtype List type of the products referenced by the suppliers
327
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
328
	 * @since 2019.04
329
	 */
330
	public function supplier( $supIds, string $listtype = 'default' ) : \Aimeos\Controller\Frontend\Product\Iface
331
	{
332
		$this->controller->supplier( $supIds, $listtype );
333
		return $this;
334
	}
335
336
337
	/**
338
	 * Adds input string for full text search
339
	 *
340
	 * @param string|null $text User input for full text search
341
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
342
	 * @since 2019.04
343
	 */
344
	public function text( string $text = null ) : \Aimeos\Controller\Frontend\Product\Iface
345
	{
346
		$this->controller->text( $text );
347
		return $this;
348
	}
349
350
351
	/**
352
	 * Sets the referenced domains that will be fetched too when retrieving items
353
	 *
354
	 * @param array $domains Domain names of the referenced items that should be fetched too
355
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
356
	 * @since 2019.04
357
	 */
358
	public function uses( array $domains ) : \Aimeos\Controller\Frontend\Product\Iface
359
	{
360
		$this->controller->uses( $domains );
361
		return $this;
362
	}
363
364
365
	/**
366
	 * Injects the reference of the outmost object
367
	 *
368
	 * @param \Aimeos\Controller\Frontend\Iface $object Reference to the outmost controller or decorator
369
	 * @return \Aimeos\Controller\Frontend\Iface Controller object for chaining method calls
370
	 */
371
	public function setObject( \Aimeos\Controller\Frontend\Iface $object ) : \Aimeos\Controller\Frontend\Iface
372
	{
373
		parent::setObject( $object );
374
375
		$this->controller->setObject( $object );
376
377
		return $this;
378
	}
379
380
381
	/**
382
	 * Returns the frontend controller
383
	 *
384
	 * @return \Aimeos\Controller\Frontend\Product\Iface Frontend controller object
385
	 */
386
	protected function getController() : \Aimeos\Controller\Frontend\Product\Iface
387
	{
388
		return $this->controller;
389
	}
390
}
391