Completed
Push — master ( 8f795c...f96435 )
by Aimeos
04:12
created
controller/frontend/src/Controller/Frontend/Product/Standard.php 1 patch
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -31,38 +31,38 @@  discard block
 block discarded – undo
31 31
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
32 32
 	 * @since 2017.03
33 33
 	 */
34
-	public function addFilterAttribute( \Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds )
34
+	public function addFilterAttribute(\Aimeos\MW\Criteria\Iface $filter, array $attrIds, array $optIds, array $oneIds)
35 35
 	{
36
-		if( ( $attrIds = $this->validateIds( $attrIds ) ) !== [] )
36
+		if (($attrIds = $this->validateIds($attrIds)) !== [])
37 37
 		{
38
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) );
38
+			$func = $filter->createFunction('index.attributeaggregate', array($attrIds));
39 39
 			$expr = array(
40
-				$filter->compare( '==', $func, count( $attrIds ) ),
40
+				$filter->compare('==', $func, count($attrIds)),
41 41
 				$filter->getConditions(),
42 42
 			);
43
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
43
+			$filter->setConditions($filter->combine('&&', $expr));
44 44
 		}
45 45
 
46
-		if( ( $optIds = $this->validateIds( $optIds ) ) !== [] )
46
+		if (($optIds = $this->validateIds($optIds)) !== [])
47 47
 		{
48
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) );
48
+			$func = $filter->createFunction('index.attributeaggregate', array($optIds));
49 49
 			$expr = array(
50
-				$filter->compare( '>', $func, 0 ),
50
+				$filter->compare('>', $func, 0),
51 51
 				$filter->getConditions(),
52 52
 			);
53
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
53
+			$filter->setConditions($filter->combine('&&', $expr));
54 54
 		}
55 55
 
56
-		foreach( $oneIds as $type => $list )
56
+		foreach ($oneIds as $type => $list)
57 57
 		{
58
-			if( ( $list = $this->validateIds( (array) $list ) ) !== [] )
58
+			if (($list = $this->validateIds((array) $list)) !== [])
59 59
 			{
60
-				$func = $filter->createFunction( 'index.attributeaggregate', array( $list ) );
60
+				$func = $filter->createFunction('index.attributeaggregate', array($list));
61 61
 				$expr = array(
62
-					$filter->compare( '>', $func, 0 ),
62
+					$filter->compare('>', $func, 0),
63 63
 					$filter->getConditions(),
64 64
 				);
65
-				$filter->setConditions( $filter->combine( '&&', $expr ) );
65
+				$filter->setConditions($filter->combine('&&', $expr));
66 66
 			}
67 67
 		}
68 68
 
@@ -82,38 +82,38 @@  discard block
 block discarded – undo
82 82
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
83 83
 	 * @since 2017.03
84 84
 	 */
85
-	public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId,
86
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' )
85
+	public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId,
86
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default')
87 87
 	{
88
-		$catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId );
88
+		$catIds = (!is_array($catId) ? explode(',', $catId) : $catId);
89 89
 
90
-		if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
90
+		if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
91 91
 		{
92 92
 			$list = [];
93
-			$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' );
93
+			$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog');
94 94
 
95
-			foreach( $catIds as $catId )
95
+			foreach ($catIds as $catId)
96 96
 			{
97
-				$tree = $cntl->getTree( $catId, [], $level );
98
-				$list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) );
97
+				$tree = $cntl->getTree($catId, [], $level);
98
+				$list = array_merge($list, $this->getCatalogIdsFromTree($tree));
99 99
 			}
100 100
 
101 101
 			$catIds = $list;
102 102
 		}
103 103
 
104
-		$expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) );
104
+		$expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds)));
105 105
 		$expr[] = $filter->getConditions();
106 106
 
107
-		if( $sort === 'relevance' )
107
+		if ($sort === 'relevance')
108 108
 		{
109
-			$cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) );
110
-			$expr[] = $filter->compare( '>=', $cmpfunc, 0 );
109
+			$cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds));
110
+			$expr[] = $filter->compare('>=', $cmpfunc, 0);
111 111
 
112
-			$sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) );
113
-			$filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) );
112
+			$sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds));
113
+			$filter->setSortations(array($filter->sort($direction, $sortfunc)));
114 114
 		}
115 115
 
116
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
116
+		$filter->setConditions($filter->combine('&&', $expr));
117 117
 
118 118
 		return $filter;
119 119
 	}
@@ -127,16 +127,16 @@  discard block
 block discarded – undo
127 127
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
128 128
 	 * @since 2018.07
129 129
 	 */
130
-	public function addFilterSupplier( \Aimeos\MW\Criteria\Iface $filter, array $supIds )
130
+	public function addFilterSupplier(\Aimeos\MW\Criteria\Iface $filter, array $supIds)
131 131
 	{
132
-		if( !empty( $supIds ) )
132
+		if (!empty($supIds))
133 133
 		{
134
-			$supIds = $this->validateIds( $supIds );
134
+			$supIds = $this->validateIds($supIds);
135 135
 			$expr = array(
136
-				$filter->compare( '==', 'index.supplier.id', $supIds ),
136
+				$filter->compare('==', 'index.supplier.id', $supIds),
137 137
 				$filter->getConditions(),
138 138
 			);
139
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
139
+			$filter->setConditions($filter->combine('&&', $expr));
140 140
 		}
141 141
 
142 142
 		return $filter;
@@ -154,13 +154,13 @@  discard block
 block discarded – undo
154 154
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
155 155
 	 * @since 2017.03
156 156
 	 */
157
-	public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' )
157
+	public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default')
158 158
 	{
159 159
 		$langid = $this->getContext()->getLocale()->getLanguageId();
160
-		$cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) );
161
-		$expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() );
160
+		$cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input));
161
+		$expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions());
162 162
 
163
-		return $filter->setConditions( $filter->combine( '&&', $expr ) );
163
+		return $filter->setConditions($filter->combine('&&', $expr));
164 164
 	}
165 165
 
166 166
 
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @return array Associative list of key values as key and the product count for this key as value
173 173
 	 * @since 2017.03
174 174
 	 */
175
-	public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key )
175
+	public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key)
176 176
 	{
177
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key );
177
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key);
178 178
 	}
179 179
 
180 180
 
@@ -189,11 +189,11 @@  discard block
 block discarded – undo
189 189
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
190 190
 	 * @since 2017.03
191 191
 	 */
192
-	public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
192
+	public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
193 193
 	{
194 194
 		$sortations = [];
195 195
 		$context = $this->getContext();
196
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'index' );
196
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'index');
197 197
 
198 198
 
199 199
 		/** controller/frontend/product/ignore-dates
@@ -208,55 +208,55 @@  discard block
 block discarded – undo
208 208
 		 * @since 2017.10
209 209
 		 * @category Developer
210 210
 		 */
211
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
211
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
212 212
 		{
213 213
 			$search = $manager->createSearch();
214
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
214
+			$search->setConditions($search->compare('>', 'product.status', 0));
215 215
 		}
216 216
 		else
217 217
 		{
218
-			$search = $manager->createSearch( true );
218
+			$search = $manager->createSearch(true);
219 219
 		}
220 220
 
221 221
 
222
-		$expr = array( $search->compare( '!=', 'index.catalog.id', null ) );
222
+		$expr = array($search->compare('!=', 'index.catalog.id', null));
223 223
 
224
-		switch( $sort )
224
+		switch ($sort)
225 225
 		{
226 226
 			case 'code':
227
-				$sortations[] = $search->sort( $direction, 'product.code' );
227
+				$sortations[] = $search->sort($direction, 'product.code');
228 228
 				break;
229 229
 
230 230
 			case 'ctime':
231
-				$sortations[] = $search->sort( $direction, 'product.ctime' );
231
+				$sortations[] = $search->sort($direction, 'product.ctime');
232 232
 				break;
233 233
 
234 234
 			case 'name':
235 235
 				$langid = $context->getLocale()->getLanguageId();
236 236
 
237
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
238
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
237
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
238
+				$expr[] = $search->compare('>=', $cmpfunc, '');
239 239
 
240
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
241
-				$sortations[] = $search->sort( $direction, $sortfunc );
240
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
241
+				$sortations[] = $search->sort($direction, $sortfunc);
242 242
 				break;
243 243
 
244 244
 			case 'price':
245 245
 				$currencyid = $context->getLocale()->getCurrencyId();
246 246
 
247
-				$cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) );
248
-				$expr[] = $search->compare( '>=', $cmpfunc, '0.00' );
247
+				$cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default'));
248
+				$expr[] = $search->compare('>=', $cmpfunc, '0.00');
249 249
 
250
-				$sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) );
251
-				$sortations[] = $search->sort( $direction, $sortfunc );
250
+				$sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default'));
251
+				$sortations[] = $search->sort($direction, $sortfunc);
252 252
 				break;
253 253
 		}
254 254
 
255 255
 		$expr[] = $search->getConditions();
256 256
 
257
-		$search->setConditions( $search->combine( '&&', $expr ) );
258
-		$search->setSortations( $sortations );
259
-		$search->setSlice( $start, $size );
257
+		$search->setConditions($search->combine('&&', $expr));
258
+		$search->setSortations($sortations);
259
+		$search->setSlice($start, $size);
260 260
 
261 261
 		return $search;
262 262
 	}
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
 	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
271 271
 	 * @since 2017.03
272 272
 	 */
273
-	public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) )
273
+	public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text'))
274 274
 	{
275
-		$items = $this->getItems( [$productId], $domains );
275
+		$items = $this->getItems([$productId], $domains);
276 276
 
277
-		if( ( $item = reset( $items ) ) !== false ) {
277
+		if (($item = reset($items)) !== false) {
278 278
 			return $item;
279 279
 		}
280 280
 
281
-		throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) );
281
+		throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId));
282 282
 	}
283 283
 
284 284
 
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values
291 291
 	 * @since 2017.03
292 292
 	 */
293
-	public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) )
293
+	public function getItems(array $productIds, array $domains = array('media', 'price', 'text'))
294 294
 	{
295 295
 		$context = $this->getContext();
296
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
296
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
297 297
 
298 298
 		/** controller/frontend/order/ignore-dates
299 299
 		 * Ignore start and end dates of products
@@ -307,24 +307,24 @@  discard block
 block discarded – undo
307 307
 		 * @since 2017.08
308 308
 		 * @category Developer
309 309
 		 */
310
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
310
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
311 311
 		{
312 312
 			$search = $manager->createSearch();
313
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
313
+			$search->setConditions($search->compare('>', 'product.status', 0));
314 314
 		}
315 315
 		else
316 316
 		{
317
-			$search = $manager->createSearch( true );
317
+			$search = $manager->createSearch(true);
318 318
 		}
319 319
 
320 320
 		$expr = array(
321
-			$search->compare( '==', 'product.id', $productIds ),
321
+			$search->compare('==', 'product.id', $productIds),
322 322
 			$search->getConditions(),
323 323
 		);
324
-		$search->setConditions( $search->combine( '&&', $expr ) );
325
-		$search->setSlice( 0, count( $productIds ) );
324
+		$search->setConditions($search->combine('&&', $expr));
325
+		$search->setSlice(0, count($productIds));
326 326
 
327
-		return $manager->searchItems( $search, $domains );
327
+		return $manager->searchItems($search, $domains);
328 328
 	}
329 329
 
330 330
 
@@ -337,9 +337,9 @@  discard block
 block discarded – undo
337 337
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
338 338
 	 * @since 2017.03
339 339
 	 */
340
-	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
340
+	public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
341 341
 	{
342
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total );
342
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total);
343 343
 	}
344 344
 
345 345
 
@@ -349,16 +349,16 @@  discard block
 block discarded – undo
349 349
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
350 350
 	 * @return array List of catalog IDs
351 351
 	 */
352
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
352
+	protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item)
353 353
 	{
354
-		if( $item->getStatus() < 1 ) {
354
+		if ($item->getStatus() < 1) {
355 355
 			return [];
356 356
 		}
357 357
 
358
-		$list = [ $item->getId() ];
358
+		$list = [$item->getId()];
359 359
 
360
-		foreach( $item->getChildren() as $child ) {
361
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
360
+		foreach ($item->getChildren() as $child) {
361
+			$list = array_merge($list, $this->getCatalogIdsFromTree($child));
362 362
 		}
363 363
 
364 364
 		return $list;
@@ -371,13 +371,13 @@  discard block
 block discarded – undo
371 371
 	 * @param array $ids List of IDs to validate
372 372
 	 * @return array List of validated IDs
373 373
 	 */
374
-	protected function validateIds( array $ids )
374
+	protected function validateIds(array $ids)
375 375
 	{
376 376
 		$list = [];
377 377
 
378
-		foreach( $ids as $id )
378
+		foreach ($ids as $id)
379 379
 		{
380
-			if( $id != '' ) {
380
+			if ($id != '') {
381 381
 				$list[] = (int) $id;
382 382
 			}
383 383
 		}
Please login to merge, or discard this patch.