Completed
Push — master ( 5f21ae...35bd2a )
by Aimeos
02:14
created
controller/frontend/src/Controller/Frontend/Product/Standard.php 1 patch
Spacing   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -31,42 +31,42 @@  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( !empty( $attrIds ) )
36
+		if (!empty($attrIds))
37 37
 		{
38
-			$attrIds = $this->validateIds( $attrIds );
38
+			$attrIds = $this->validateIds($attrIds);
39 39
 
40
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $attrIds ) );
40
+			$func = $filter->createFunction('index.attributeaggregate', array($attrIds));
41 41
 			$expr = array(
42
-				$filter->compare( '==', $func, count( $attrIds ) ),
42
+				$filter->compare('==', $func, count($attrIds)),
43 43
 				$filter->getConditions(),
44 44
 			);
45
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
45
+			$filter->setConditions($filter->combine('&&', $expr));
46 46
 		}
47 47
 
48
-		if( !empty( $optIds ) )
48
+		if (!empty($optIds))
49 49
 		{
50
-			$optIds = $this->validateIds( $optIds );
50
+			$optIds = $this->validateIds($optIds);
51 51
 
52
-			$func = $filter->createFunction( 'index.attributeaggregate', array( $optIds ) );
52
+			$func = $filter->createFunction('index.attributeaggregate', array($optIds));
53 53
 			$expr = array(
54
-				$filter->compare( '>', $func, 0 ),
54
+				$filter->compare('>', $func, 0),
55 55
 				$filter->getConditions(),
56 56
 			);
57
-			$filter->setConditions( $filter->combine( '&&', $expr ) );
57
+			$filter->setConditions($filter->combine('&&', $expr));
58 58
 		}
59 59
 
60
-		foreach( $oneIds as $type => $list )
60
+		foreach ($oneIds as $type => $list)
61 61
 		{
62
-			if( ( $list = $this->validateIds( (array) $list ) ) !== [] )
62
+			if (($list = $this->validateIds((array) $list)) !== [])
63 63
 			{
64
-				$func = $filter->createFunction( 'index.attributeaggregate', array( $list ) );
64
+				$func = $filter->createFunction('index.attributeaggregate', array($list));
65 65
 				$expr = array(
66
-					$filter->compare( '>', $func, 0 ),
66
+					$filter->compare('>', $func, 0),
67 67
 					$filter->getConditions(),
68 68
 				);
69
-				$filter->setConditions( $filter->combine( '&&', $expr ) );
69
+				$filter->setConditions($filter->combine('&&', $expr));
70 70
 			}
71 71
 		}
72 72
 
@@ -86,38 +86,38 @@  discard block
 block discarded – undo
86 86
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
87 87
 	 * @since 2017.03
88 88
 	 */
89
-	public function addFilterCategory( \Aimeos\MW\Criteria\Iface $filter, $catId,
90
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default' )
89
+	public function addFilterCategory(\Aimeos\MW\Criteria\Iface $filter, $catId,
90
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE, $sort = null, $direction = '+', $listtype = 'default')
91 91
 	{
92
-		$catIds = ( !is_array( $catId ) ? explode( ',', $catId ) : $catId );
92
+		$catIds = (!is_array($catId) ? explode(',', $catId) : $catId);
93 93
 
94
-		if( $level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE )
94
+		if ($level != \Aimeos\MW\Tree\Manager\Base::LEVEL_ONE)
95 95
 		{
96 96
 			$list = [];
97
-			$cntl = \Aimeos\Controller\Frontend\Factory::createController( $this->getContext(), 'catalog' );
97
+			$cntl = \Aimeos\Controller\Frontend\Factory::createController($this->getContext(), 'catalog');
98 98
 
99
-			foreach( $catIds as $catId )
99
+			foreach ($catIds as $catId)
100 100
 			{
101
-				$tree = $cntl->getCatalogTree( $catId, [], $level );
102
-				$list = array_merge( $list, $this->getCatalogIdsFromTree( $tree ) );
101
+				$tree = $cntl->getCatalogTree($catId, [], $level);
102
+				$list = array_merge($list, $this->getCatalogIdsFromTree($tree));
103 103
 			}
104 104
 
105 105
 			$catIds = $list;
106 106
 		}
107 107
 
108
-		$expr = array( $filter->compare( '==', 'index.catalog.id', array_unique( $catIds ) ) );
108
+		$expr = array($filter->compare('==', 'index.catalog.id', array_unique($catIds)));
109 109
 		$expr[] = $filter->getConditions();
110 110
 
111
-		if( $sort === 'relevance' )
111
+		if ($sort === 'relevance')
112 112
 		{
113
-			$cmpfunc = $filter->createFunction( 'index.catalog.position', array( $listtype, $catIds ) );
114
-			$expr[] = $filter->compare( '>=', $cmpfunc, 0 );
113
+			$cmpfunc = $filter->createFunction('index.catalog.position', array($listtype, $catIds));
114
+			$expr[] = $filter->compare('>=', $cmpfunc, 0);
115 115
 
116
-			$sortfunc = $filter->createFunction( 'sort:index.catalog.position', array( $listtype, $catIds ) );
117
-			$filter->setSortations( array( $filter->sort( $direction, $sortfunc ) ) );
116
+			$sortfunc = $filter->createFunction('sort:index.catalog.position', array($listtype, $catIds));
117
+			$filter->setSortations(array($filter->sort($direction, $sortfunc)));
118 118
 		}
119 119
 
120
-		$filter->setConditions( $filter->combine( '&&', $expr ) );
120
+		$filter->setConditions($filter->combine('&&', $expr));
121 121
 
122 122
 		return $filter;
123 123
 	}
@@ -134,13 +134,13 @@  discard block
 block discarded – undo
134 134
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
135 135
 	 * @since 2017.03
136 136
 	 */
137
-	public function addFilterText( \Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default' )
137
+	public function addFilterText(\Aimeos\MW\Criteria\Iface $filter, $input, $sort = null, $direction = '+', $listtype = 'default')
138 138
 	{
139 139
 		$langid = $this->getContext()->getLocale()->getLanguageId();
140
-		$cmpfunc = $filter->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) );
141
-		$expr = array( $filter->compare( '>', $cmpfunc, 0 ), $filter->getConditions() );
140
+		$cmpfunc = $filter->createFunction('index.text.relevance', array($listtype, $langid, $input));
141
+		$expr = array($filter->compare('>', $cmpfunc, 0), $filter->getConditions());
142 142
 
143
-		return $filter->setConditions( $filter->combine( '&&', $expr ) );
143
+		return $filter->setConditions($filter->combine('&&', $expr));
144 144
 	}
145 145
 
146 146
 
@@ -152,9 +152,9 @@  discard block
 block discarded – undo
152 152
 	 * @return array Associative list of key values as key and the product count for this key as value
153 153
 	 * @since 2017.03
154 154
 	 */
155
-	public function aggregate( \Aimeos\MW\Criteria\Iface $filter, $key )
155
+	public function aggregate(\Aimeos\MW\Criteria\Iface $filter, $key)
156 156
 	{
157
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key );
157
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key);
158 158
 	}
159 159
 
160 160
 
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
170 170
 	 * @since 2017.03
171 171
 	 */
172
-	public function createFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
172
+	public function createFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
173 173
 	{
174 174
 		$sortations = [];
175 175
 		$context = $this->getContext();
176
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'index' );
176
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'index');
177 177
 
178 178
 
179 179
 		/** controller/frontend/product/ignore-dates
@@ -188,55 +188,55 @@  discard block
 block discarded – undo
188 188
 		 * @since 2017.10
189 189
 		 * @category Developer
190 190
 		 */
191
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
191
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
192 192
 		{
193 193
 			$search = $manager->createSearch();
194
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
194
+			$search->setConditions($search->compare('>', 'product.status', 0));
195 195
 		}
196 196
 		else
197 197
 		{
198
-			$search = $manager->createSearch( true );
198
+			$search = $manager->createSearch(true);
199 199
 		}
200 200
 
201 201
 
202
-		$expr = array( $search->compare( '!=', 'index.catalog.id', null ) );
202
+		$expr = array($search->compare('!=', 'index.catalog.id', null));
203 203
 
204
-		switch( $sort )
204
+		switch ($sort)
205 205
 		{
206 206
 			case 'code':
207
-				$sortations[] = $search->sort( $direction, 'product.code' );
207
+				$sortations[] = $search->sort($direction, 'product.code');
208 208
 				break;
209 209
 
210 210
 			case 'ctime':
211
-				$sortations[] = $search->sort( $direction, 'product.ctime' );
211
+				$sortations[] = $search->sort($direction, 'product.ctime');
212 212
 				break;
213 213
 
214 214
 			case 'name':
215 215
 				$langid = $context->getLocale()->getLanguageId();
216 216
 
217
-				$cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) );
218
-				$expr[] = $search->compare( '>=', $cmpfunc, '' );
217
+				$cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product'));
218
+				$expr[] = $search->compare('>=', $cmpfunc, '');
219 219
 
220
-				$sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) );
221
-				$sortations[] = $search->sort( $direction, $sortfunc );
220
+				$sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name'));
221
+				$sortations[] = $search->sort($direction, $sortfunc);
222 222
 				break;
223 223
 
224 224
 			case 'price':
225 225
 				$currencyid = $context->getLocale()->getCurrencyId();
226 226
 
227
-				$cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) );
228
-				$expr[] = $search->compare( '>=', $cmpfunc, '0.00' );
227
+				$cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default'));
228
+				$expr[] = $search->compare('>=', $cmpfunc, '0.00');
229 229
 
230
-				$sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) );
231
-				$sortations[] = $search->sort( $direction, $sortfunc );
230
+				$sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default'));
231
+				$sortations[] = $search->sort($direction, $sortfunc);
232 232
 				break;
233 233
 		}
234 234
 
235 235
 		$expr[] = $search->getConditions();
236 236
 
237
-		$search->setConditions( $search->combine( '&&', $expr ) );
238
-		$search->setSortations( $sortations );
239
-		$search->setSlice( $start, $size );
237
+		$search->setConditions($search->combine('&&', $expr));
238
+		$search->setSortations($sortations);
239
+		$search->setSlice($start, $size);
240 240
 
241 241
 		return $search;
242 242
 	}
@@ -250,15 +250,15 @@  discard block
 block discarded – undo
250 250
 	 * @return \Aimeos\MShop\Product\Item\Iface Product item including the referenced domains items
251 251
 	 * @since 2017.03
252 252
 	 */
253
-	public function getItem( $productId, array $domains = array( 'attribute', 'media', 'price', 'product', 'product/property', 'text' ) )
253
+	public function getItem($productId, array $domains = array('attribute', 'media', 'price', 'product', 'product/property', 'text'))
254 254
 	{
255
-		$items = $this->getItems( [$productId], $domains );
255
+		$items = $this->getItems([$productId], $domains);
256 256
 
257
-		if( ( $item = reset( $items ) ) !== false ) {
257
+		if (($item = reset($items)) !== false) {
258 258
 			return $item;
259 259
 		}
260 260
 
261
-		throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Product item with ID "%1$s" not found', $productId ) );
261
+		throw new \Aimeos\Controller\Frontend\Exception(sprintf('Product item with ID "%1$s" not found', $productId));
262 262
 	}
263 263
 
264 264
 
@@ -270,10 +270,10 @@  discard block
 block discarded – undo
270 270
 	 * @return \Aimeos\MShop\Product\Item\Iface[] Associative list of product IDs as keys and product items as values
271 271
 	 * @since 2017.03
272 272
 	 */
273
-	public function getItems( array $productIds, array $domains = array( 'media', 'price', 'text' ) )
273
+	public function getItems(array $productIds, array $domains = array('media', 'price', 'text'))
274 274
 	{
275 275
 		$context = $this->getContext();
276
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
276
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
277 277
 
278 278
 		/** controller/frontend/order/ignore-dates
279 279
 		 * Ignore start and end dates of products
@@ -287,24 +287,24 @@  discard block
 block discarded – undo
287 287
 		 * @since 2017.08
288 288
 		 * @category Developer
289 289
 		 */
290
-		if( $context->getConfig()->get( 'controller/frontend/product/ignore-dates', false ) )
290
+		if ($context->getConfig()->get('controller/frontend/product/ignore-dates', false))
291 291
 		{
292 292
 			$search = $manager->createSearch();
293
-			$search->setConditions( $search->compare( '>', 'product.status', 0 ) );
293
+			$search->setConditions($search->compare('>', 'product.status', 0));
294 294
 		}
295 295
 		else
296 296
 		{
297
-			$search = $manager->createSearch( true );
297
+			$search = $manager->createSearch(true);
298 298
 		}
299 299
 
300 300
 		$expr = array(
301
-			$search->compare( '==', 'product.id', $productIds ),
301
+			$search->compare('==', 'product.id', $productIds),
302 302
 			$search->getConditions(),
303 303
 		);
304
-		$search->setConditions( $search->combine( '&&', $expr ) );
305
-		$search->setSlice( 0, count( $productIds ) );
304
+		$search->setConditions($search->combine('&&', $expr));
305
+		$search->setSlice(0, count($productIds));
306 306
 
307
-		return $manager->searchItems( $search, $domains );
307
+		return $manager->searchItems($search, $domains);
308 308
 	}
309 309
 
310 310
 
@@ -317,9 +317,9 @@  discard block
 block discarded – undo
317 317
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
318 318
 	 * @since 2017.03
319 319
 	 */
320
-	public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
320
+	public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
321 321
 	{
322
-		return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total );
322
+		return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total);
323 323
 	}
324 324
 
325 325
 
@@ -329,12 +329,12 @@  discard block
 block discarded – undo
329 329
 	 * @param \Aimeos\MShop\Catalog\Item\Iface $item Catalog item with children
330 330
 	 * @return array List of catalog IDs
331 331
 	 */
332
-	protected function getCatalogIdsFromTree( \Aimeos\MShop\Catalog\Item\Iface $item )
332
+	protected function getCatalogIdsFromTree(\Aimeos\MShop\Catalog\Item\Iface $item)
333 333
 	{
334
-		$list = array( $item->getId() );
334
+		$list = array($item->getId());
335 335
 
336
-		foreach( $item->getChildren() as $child ) {
337
-			$list = array_merge( $list, $this->getCatalogIdsFromTree( $child ) );
336
+		foreach ($item->getChildren() as $child) {
337
+			$list = array_merge($list, $this->getCatalogIdsFromTree($child));
338 338
 		}
339 339
 
340 340
 		return $list;
@@ -347,13 +347,13 @@  discard block
 block discarded – undo
347 347
 	 * @param array $ids List of IDs to validate
348 348
 	 * @return array List of validated IDs
349 349
 	 */
350
-	protected function validateIds( array $ids )
350
+	protected function validateIds(array $ids)
351 351
 	{
352 352
 		$list = [];
353 353
 
354
-		foreach( $ids as $id )
354
+		foreach ($ids as $id)
355 355
 		{
356
-			if( $id != '' ) {
356
+			if ($id != '') {
357 357
 				$list[] = (int) $id;
358 358
 			}
359 359
 		}
Please login to merge, or discard this patch.