Completed
Push — master ( 75d10e...433dcb )
by Aimeos
01:39
created

Base::find()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/**
4
 * @license LGPLv3, http://opensource.org/licenses/LGPL-3.0
5
 * @copyright Aimeos (aimeos.org), 2016-2018
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
		\Aimeos\MW\Common\Base::checkClass( '\\Aimeos\\Controller\\Frontend\\Product\\Iface', $controller );
36
37
		$this->controller = $controller;
38
39
		parent::__construct( $context );
40
	}
41
42
43
	/**
44
	 * Passes unknown methods to wrapped objects.
45
	 *
46
	 * @param string $name Name of the method
47
	 * @param array $param List of method parameter
48
	 * @return mixed Returns the value of the called method
49
	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
50
	 */
51
	public function __call( $name, array $param )
52
	{
53
		return @call_user_func_array( array( $this->controller, $name ), $param );
54
	}
55
56
57
	/**
58
	 * Returns the aggregated count of products for the given key.
59
	 *
60
	 * @param string $key Search key to aggregate for, e.g. "index.attribute.id"
61
	 * @return array Associative list of key values as key and the product count for this key as value
62
	 * @since 2019.04
63
	 */
64
	public function aggregate( $key )
65
	{
66
		return $this->controller->aggregate( $key );
67
	}
68
69
70
	/**
71
	 * Adds attribute IDs for filtering where products must reference all IDs
72
	 *
73
	 * @param array|string $attrIds Attribute ID or list of IDs
74
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
75
	 * @since 2019.04
76
	 */
77
	public function allOf( $attrIds )
78
	{
79
		$this->controller->allOf( $attrIds );
80
		return $this;
81
	}
82
83
84
	/**
85
	 * Adds catalog IDs for filtering
86
	 *
87
	 * @param array|string $catIds Catalog ID or list of IDs
88
	 * @param string $listtype List type of the products referenced by the categories
89
	 * @param integer $level Constant from \Aimeos\MW\Tree\Manager\Base if products in subcategories are matched too
90
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
91
	 * @since 2019.04
92
	 */
93
	public function category( $catIds, $listtype = 'default', $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
94
	{
95
		$this->controller->category( $catIds, $listtype, $level );
96
		return $this;
97
	}
98
99
100
	/**
101
	 * Adds generic condition for filtering products
102
	 *
103
	 * @param string $operator Comparison operator, e.g. "==", "!=", "<", "<=", ">=", ">", "=~", "~="
104
	 * @param string $key Search key defined by the product manager, e.g. "product.status"
105
	 * @param array|string $value Value or list of values to compare to
106
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
107
	 * @since 2019.04
108
	 */
109
	public function compare( $operator, $key, $value )
110
	{
111
		$this->controller->compare( $operator, $key, $value );
112
		return $this;
113
	}
114
115
116
	/**
117
	 * Returns the product for the given product ID
118
	 *
119
	 * @param string $id Unique product ID
120
	 * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too
121
	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
122
	 * @since 2019.04
123
	 */
124
	public function get( $id, $domains = ['media', 'price', 'text'] )
125
	{
126
		return $this->controller->get( $id, $domains );
127
	}
128
129
130
	/**
131
	 * Returns the product for the given product code
132
	 *
133
	 * @param string $code Unique product code
134
	 * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too
135
	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
136
	 * @since 2019.04
137
	 */
138
	public function find( $code, $domains = ['media', 'price', 'text'] )
139
	{
140
		return $this->controller->find( $code, $domains );
141
	}
142
143
144
	/**
145
	 * Adds attribute IDs for filtering where products must reference at least one ID
146
	 *
147
	 * @param array|string $attrIds Attribute ID or list of IDs
148
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
149
	 * @since 2019.04
150
	 */
151
	public function oneOf( $attrIds )
152
	{
153
		$this->controller->oneOf( $attrIds );
154
		return $this;
155
	}
156
157
158
	/**
159
	 * Parses the given array and adds the conditions to the list of conditions
160
	 *
161
	 * @param array $conditions List of conditions, e.g. ['&&' => [['>' => ['product.status' => 0]], ['==' => ['product.type' => 'default']]]]
162
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
163
	 * @since 2019.04
164
	 */
165
	public function parse( array $conditions )
166
	{
167
		$this->controller->parse( $conditions );
168
		return $this;
169
	}
170
171
172
	/**
173
	 * Adds product IDs for filtering
174
	 *
175
	 * @param array|string $prodIds Product ID or list of IDs
176
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
177
	 * @since 2019.04
178
	 */
179
	public function product( $prodIds )
180
	{
181
		$this->controller->product( $prodIds );
182
		return $this;
183
	}
184
185
186
	/**
187
	 * Returns the products filtered by the previously assigned conditions
188
	 *
189
	 * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too
190
	 * @param integer &$total Parameter where the total number of found products will be stored in
191
	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
192
	 * @since 2019.04
193
	 */
194
	public function search( $domains = ['media', 'price', 'text'], &$total = null )
195
	{
196
		return $this->controller->search( $domains, $total );
197
	}
198
199
200
	/**
201
	 * Sets the start value and the number of returned products for slicing the list of found products
202
	 *
203
	 * @param integer $start Start value of the first product in the list
204
	 * @param integer $limit Number of returned products
205
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
206
	 * @since 2019.04
207
	 */
208
	public function slice( $start, $limit )
209
	{
210
		$this->controller->slice( $start, $limit );
211
		return $this;
212
	}
213
214
215
	/**
216
	 * Sets the sorting of the product list
217
	 *
218
	 * @param string|null $sort Sortation of the product list like "name", "-name", "price", "-price", "code", "-code", "ctime, "-ctime" and "relevance", null for no sortation
0 ignored issues
show
Bug introduced by
There is no parameter named $sort. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
219
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
220
	 * @since 2019.04
221
	 */
222
	public function sort( $key = null )
223
	{
224
		$this->controller->sort( $key );
225
		return $this;
226
	}
227
228
229
	/**
230
	 * Adds supplier IDs for filtering
231
	 *
232
	 * @param array|string $supIds Supplier ID or list of IDs
233
	 * @param string $listtype List type of the products referenced by the suppliers
234
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
235
	 * @since 2019.04
236
	 */
237
	public function supplier( $supIds, $listtype = 'default' )
238
	{
239
		$this->controller->supplier( $supIds, $listtype );
240
		return $this;
241
	}
242
243
244
	/**
245
	 * Adds input string for full text search
246
	 *
247
	 * @param string|null $text User input for full text search
248
	 * @return \Aimeos\Controller\Frontend\Product\Iface Product controller for fluent interface
249
	 * @since 2019.04
250
	 */
251
	public function text( $text )
252
	{
253
		$this->controller->text( $text );
254
		return $this;
255
	}
256
257
258
	/**
259
	 * Returns the frontend controller
260
	 *
261
	 * @return \Aimeos\Controller\Frontend\Product\Iface Frontend controller object
262
	 */
263
	protected function getController()
264
	{
265
		return $this->controller;
266
	}
267
}
268