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