Completed
Push — master ( 2a954a...31dc8b )
by Aimeos
02:47
created
controller/frontend/src/Controller/Frontend/Basket/Base.php 1 patch
Spacing   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -31,32 +31,32 @@  discard block
 block discarded – undo
31 31
 	 * @param integer $quantity New product quantity
32 32
 	 * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price
33 33
 	 */
34
-	protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity )
34
+	protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity)
35 35
 	{
36 36
 		$context = $this->getContext();
37 37
 
38
-		if( empty( $prices ) )
38
+		if (empty($prices))
39 39
 		{
40
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
41
-			$prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' );
40
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
41
+			$prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default');
42 42
 		}
43 43
 
44
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
45
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
44
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
45
+		$price = $priceManager->getLowestPrice($prices, $quantity);
46 46
 
47
-		foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem )
47
+		foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem)
48 48
 		{
49
-			$prices = $attrItem->getRefItems( 'price', 'default' );
49
+			$prices = $attrItem->getRefItems('price', 'default');
50 50
 
51
-			if( count( $prices ) > 0 )
51
+			if (count($prices) > 0)
52 52
 			{
53
-				$attrPrice = $priceManager->getLowestPrice( $prices, $quantity );
54
-				$price->addItem( $attrPrice );
53
+				$attrPrice = $priceManager->getLowestPrice($prices, $quantity);
54
+				$price->addItem($attrPrice);
55 55
 			}
56 56
 		}
57 57
 
58 58
 		// remove product rebate of original price in favor to rebates granted for the order
59
-		$price->setRebate( '0.00' );
59
+		$price->setRebate('0.00');
60 60
 
61 61
 		return $price;
62 62
 	}
@@ -71,34 +71,34 @@  discard block
 block discarded – undo
71 71
 	 * @param array $refIds List of IDs that must be associated to the product
72 72
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
73 73
 	 */
74
-	protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds )
74
+	protected function checkReferences($prodId, $domain, $listTypeId, array $refIds)
75 75
 	{
76
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
77
-		$search = $productManager->createSearch( true );
76
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
77
+		$search = $productManager->createSearch(true);
78 78
 
79 79
 		$expr = array(
80
-			$search->compare( '==', 'product.id', $prodId ),
80
+			$search->compare('==', 'product.id', $prodId),
81 81
 			$search->getConditions(),
82 82
 		);
83 83
 
84
-		if( count( $refIds ) > 0 )
84
+		if (count($refIds) > 0)
85 85
 		{
86
-			foreach( $refIds as $key => $refId ) {
86
+			foreach ($refIds as $key => $refId) {
87 87
 				$refIds[$key] = (string) $refId;
88 88
 			}
89 89
 
90
-			$param = array( $domain, $listTypeId, $refIds );
91
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
90
+			$param = array($domain, $listTypeId, $refIds);
91
+			$cmpfunc = $search->createFunction('product.contains', $param);
92 92
 
93
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
93
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
94 94
 		}
95 95
 
96
-		$search->setConditions( $search->combine( '&&', $expr ) );
96
+		$search->setConditions($search->combine('&&', $expr));
97 97
 
98
-		if( count( $productManager->searchItems( $search, array() ) ) === 0 )
98
+		if (count($productManager->searchItems($search, array())) === 0)
99 99
 		{
100
-			$msg = sprintf( 'Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId );
101
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
100
+			$msg = sprintf('Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId);
101
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
102 102
 		}
103 103
 	}
104 104
 
@@ -113,34 +113,34 @@  discard block
 block discarded – undo
113 113
 		$session = $context->getSession();
114 114
 		$locale = $this->get()->getLocale();
115 115
 
116
-		$localeStr = $session->get( 'aimeos/basket/locale' );
116
+		$localeStr = $session->get('aimeos/basket/locale');
117 117
 		$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
118 118
 
119
-		if( $localeStr !== null && $localeStr !== $localeKey )
119
+		if ($localeStr !== null && $localeStr !== $localeKey)
120 120
 		{
121
-			$locParts = explode( '|', $localeStr );
122
-			$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
123
-			$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
124
-			$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
121
+			$locParts = explode('|', $localeStr);
122
+			$locSite = (isset($locParts[0]) ? $locParts[0] : '');
123
+			$locLanguage = (isset($locParts[1]) ? $locParts[1] : '');
124
+			$locCurrency = (isset($locParts[2]) ? $locParts[2] : '');
125 125
 
126
-			$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
127
-			$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
126
+			$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
127
+			$locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false);
128 128
 
129 129
 			$context = clone $context;
130
-			$context->setLocale( $locale );
130
+			$context->setLocale($locale);
131 131
 
132
-			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' );
132
+			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base');
133 133
 			$basket = $manager->getSession();
134 134
 
135
-			$this->copyAddresses( $basket, $errors, $localeKey );
136
-			$this->copyServices( $basket, $errors );
137
-			$this->copyProducts( $basket, $errors, $localeKey );
138
-			$this->copyCoupons( $basket, $errors, $localeKey );
135
+			$this->copyAddresses($basket, $errors, $localeKey);
136
+			$this->copyServices($basket, $errors);
137
+			$this->copyProducts($basket, $errors, $localeKey);
138
+			$this->copyCoupons($basket, $errors, $localeKey);
139 139
 
140
-			$manager->setSession( $basket );
140
+			$manager->setSession($basket);
141 141
 		}
142 142
 
143
-		$session->set( 'aimeos/basket/locale', $localeKey );
143
+		$session->set('aimeos/basket/locale', $localeKey);
144 144
 	}
145 145
 
146 146
 
@@ -152,20 +152,20 @@  discard block
 block discarded – undo
152 152
 	 * @param string $localeKey Unique identifier of the site, language and currency
153 153
 	 * @return array Associative list of errors occured
154 154
 	 */
155
-	protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
155
+	protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
156 156
 	{
157
-		foreach( $basket->getAddresses() as $type => $item )
157
+		foreach ($basket->getAddresses() as $type => $item)
158 158
 		{
159 159
 			try
160 160
 			{
161
-				$this->setAddress( $type, $item->toArray() );
162
-				$basket->deleteAddress( $type );
161
+				$this->setAddress($type, $item->toArray());
162
+				$basket->deleteAddress($type);
163 163
 			}
164
-			catch( \Exception $e )
164
+			catch (\Exception $e)
165 165
 			{
166 166
 				$logger = $this->getContext()->getLogger();
167 167
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
168
-				$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
168
+				$logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
169 169
 				$errors['address'][$type] = $e->getMessage();
170 170
 			}
171 171
 		}
@@ -182,20 +182,20 @@  discard block
 block discarded – undo
182 182
 	 * @param string $localeKey Unique identifier of the site, language and currency
183 183
 	 * @return array Associative list of errors occured
184 184
 	 */
185
-	protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
185
+	protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
186 186
 	{
187
-		foreach( $basket->getCoupons() as $code => $list )
187
+		foreach ($basket->getCoupons() as $code => $list)
188 188
 		{
189 189
 			try
190 190
 			{
191
-				$this->addCoupon( $code );
192
-				$basket->deleteCoupon( $code, true );
191
+				$this->addCoupon($code);
192
+				$basket->deleteCoupon($code, true);
193 193
 			}
194
-			catch( \Exception $e )
194
+			catch (\Exception $e)
195 195
 			{
196 196
 				$logger = $this->getContext()->getLogger();
197 197
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
198
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
198
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
199 199
 				$errors['coupon'][$code] = $e->getMessage();
200 200
 			}
201 201
 		}
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	 * @param string $localeKey Unique identifier of the site, language and currency
213 213
 	 * @return array Associative list of errors occured
214 214
 	 */
215
-	protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
215
+	protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
216 216
 	{
217
-		foreach( $basket->getProducts() as $pos => $product )
217
+		foreach ($basket->getProducts() as $pos => $product)
218 218
 		{
219
-			if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) {
219
+			if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) {
220 220
 				continue;
221 221
 			}
222 222
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 			{
225 225
 				$attrIds = array();
226 226
 
227
-				foreach( $product->getAttributes() as $attrItem ) {
227
+				foreach ($product->getAttributes() as $attrItem) {
228 228
 					$attrIds[$attrItem->getType()][] = $attrItem->getAttributeId();
229 229
 				}
230 230
 
@@ -232,21 +232,21 @@  discard block
 block discarded – undo
232 232
 						$product->getProductId(),
233 233
 						$product->getQuantity(),
234 234
 						array(),
235
-						$this->getValue( $attrIds, 'variant', array() ),
236
-						$this->getValue( $attrIds, 'config', array() ),
237
-						$this->getValue( $attrIds, 'hidden', array() ),
238
-						$this->getValue( $attrIds, 'custom', array() ),
235
+						$this->getValue($attrIds, 'variant', array()),
236
+						$this->getValue($attrIds, 'config', array()),
237
+						$this->getValue($attrIds, 'hidden', array()),
238
+						$this->getValue($attrIds, 'custom', array()),
239 239
 						$product->getWarehouseCode()
240 240
 				);
241 241
 
242
-				$basket->deleteProduct( $pos );
242
+				$basket->deleteProduct($pos);
243 243
 			}
244
-			catch( \Exception $e )
244
+			catch (\Exception $e)
245 245
 			{
246 246
 				$code = $product->getProductCode();
247 247
 				$logger = $this->getContext()->getLogger();
248 248
 				$str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s';
249
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
249
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
250 250
 				$errors['product'][$pos] = $e->getMessage();
251 251
 			}
252 252
 		}
@@ -262,22 +262,22 @@  discard block
 block discarded – undo
262 262
 	 * @param array $errors Associative list of previous errors
263 263
 	 * @return array Associative list of errors occured
264 264
 	 */
265
-	protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
265
+	protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors)
266 266
 	{
267
-		foreach( $basket->getServices() as $type => $item )
267
+		foreach ($basket->getServices() as $type => $item)
268 268
 		{
269 269
 			try
270 270
 			{
271 271
 				$attributes = array();
272 272
 
273
-				foreach( $item->getAttributes() as $attrItem ) {
273
+				foreach ($item->getAttributes() as $attrItem) {
274 274
 					$attributes[$attrItem->getCode()] = $attrItem->getValue();
275 275
 				}
276 276
 
277
-				$this->setService( $type, $item->getServiceId(), $attributes );
278
-				$basket->deleteService( $type );
277
+				$this->setService($type, $item->getServiceId(), $attributes);
278
+				$basket->deleteService($type);
279 279
 			}
280
-			catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
280
+			catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically
281 281
 		}
282 282
 
283 283
 		return $errors;
@@ -292,31 +292,31 @@  discard block
 block discarded – undo
292 292
 	 * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
293 293
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
294 294
 	 */
295
-	protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) )
295
+	protected function getAttributes(array $attributeIds, array $domains = array('price', 'text'))
296 296
 	{
297
-		if( empty( $attributeIds ) ) {
297
+		if (empty($attributeIds)) {
298 298
 			return array();
299 299
 		}
300 300
 
301
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
301
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
302 302
 
303
-		$search = $attributeManager->createSearch( true );
303
+		$search = $attributeManager->createSearch(true);
304 304
 		$expr = array(
305
-				$search->compare( '==', 'attribute.id', $attributeIds ),
305
+				$search->compare('==', 'attribute.id', $attributeIds),
306 306
 				$search->getConditions(),
307 307
 		);
308
-		$search->setConditions( $search->combine( '&&', $expr ) );
309
-		$search->setSlice( 0, 0x7fffffff );
308
+		$search->setConditions($search->combine('&&', $expr));
309
+		$search->setSlice(0, 0x7fffffff);
310 310
 
311
-		$attrItems = $attributeManager->searchItems( $search, $domains );
311
+		$attrItems = $attributeManager->searchItems($search, $domains);
312 312
 
313
-		if( count( $attrItems ) !== count( $attributeIds ) )
313
+		if (count($attrItems) !== count($attributeIds))
314 314
 		{
315
-			$expected = implode( ',', $attributeIds );
316
-			$actual = implode( ',', array_keys( $attrItems ) );
317
-			$msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected );
315
+			$expected = implode(',', $attributeIds);
316
+			$actual = implode(',', array_keys($attrItems));
317
+			$msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected);
318 318
 
319
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
319
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
320 320
 		}
321 321
 
322 322
 		return $attrItems;
@@ -329,31 +329,31 @@  discard block
 block discarded – undo
329 329
 	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
330 330
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
331 331
 	 */
332
-	protected function getAttributeItems( array $orderAttributes )
332
+	protected function getAttributeItems(array $orderAttributes)
333 333
 	{
334
-		if( empty( $orderAttributes ) ) {
334
+		if (empty($orderAttributes)) {
335 335
 			return array();
336 336
 		}
337 337
 
338
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
339
-		$search = $attributeManager->createSearch( true );
338
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
339
+		$search = $attributeManager->createSearch(true);
340 340
 		$expr = array();
341 341
 
342
-		foreach( $orderAttributes as $item )
342
+		foreach ($orderAttributes as $item)
343 343
 		{
344 344
 			$tmp = array(
345
-				$search->compare( '==', 'attribute.domain', 'product' ),
346
-				$search->compare( '==', 'attribute.code', $item->getValue() ),
347
-				$search->compare( '==', 'attribute.type.domain', 'product' ),
348
-				$search->compare( '==', 'attribute.type.code', $item->getCode() ),
349
-				$search->compare( '>', 'attribute.type.status', 0 ),
345
+				$search->compare('==', 'attribute.domain', 'product'),
346
+				$search->compare('==', 'attribute.code', $item->getValue()),
347
+				$search->compare('==', 'attribute.type.domain', 'product'),
348
+				$search->compare('==', 'attribute.type.code', $item->getCode()),
349
+				$search->compare('>', 'attribute.type.status', 0),
350 350
 				$search->getConditions(),
351 351
 			);
352
-			$expr[] = $search->combine( '&&', $tmp );
352
+			$expr[] = $search->combine('&&', $tmp);
353 353
 		}
354 354
 
355
-		$search->setConditions( $search->combine( '||', $expr ) );
356
-		return $attributeManager->searchItems( $search, array( 'price' ) );
355
+		$search->setConditions($search->combine('||', $expr));
356
+		return $attributeManager->searchItems($search, array('price'));
357 357
 	}
358 358
 
359 359
 
@@ -364,26 +364,26 @@  discard block
 block discarded – undo
364 364
 	 * @param string $code Code of the list type
365 365
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface List type item
366 366
 	 */
367
-	protected function getProductListTypeItem( $domain, $code )
367
+	protected function getProductListTypeItem($domain, $code)
368 368
 	{
369
-		if( !isset( $this->listTypeAttributes[$domain][$code] ) )
369
+		if (!isset($this->listTypeAttributes[$domain][$code]))
370 370
 		{
371
-			$listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' );
371
+			$listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type');
372 372
 
373
-			$listTypeSearch = $listTypeManager->createSearch( true );
373
+			$listTypeSearch = $listTypeManager->createSearch(true);
374 374
 			$expr = array(
375
-				$listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ),
376
-				$listTypeSearch->compare( '==', 'product.lists.type.code', $code ),
375
+				$listTypeSearch->compare('==', 'product.lists.type.domain', $domain),
376
+				$listTypeSearch->compare('==', 'product.lists.type.code', $code),
377 377
 				$listTypeSearch->getConditions(),
378 378
 			);
379
-			$listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) );
379
+			$listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr));
380 380
 
381
-			$listTypeItems = $listTypeManager->searchItems( $listTypeSearch );
381
+			$listTypeItems = $listTypeManager->searchItems($listTypeSearch);
382 382
 
383
-			if( ( $listTypeItem = reset( $listTypeItems ) ) === false )
383
+			if (($listTypeItem = reset($listTypeItems)) === false)
384 384
 			{
385
-				$msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code );
386
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
385
+				$msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code);
386
+				throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
387 387
 			}
388 388
 
389 389
 			$this->listTypeAttributes[$domain][$code] = $listTypeItem;
@@ -401,43 +401,43 @@  discard block
 block discarded – undo
401 401
 	 * @param array $domains Names of the domain items that should be fetched too
402 402
 	 * @return array List of products matching the given attributes
403 403
 	 */
404
-	protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
405
-			array $domains = array( 'attribute', 'media', 'price', 'text' ) )
404
+	protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
405
+			array $domains = array('attribute', 'media', 'price', 'text'))
406 406
 	{
407 407
 		$subProductIds = array();
408
-		foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) {
408
+		foreach ($productItem->getRefItems('product', 'default', 'default') as $item) {
409 409
 			$subProductIds[] = $item->getId();
410 410
 		}
411 411
 
412
-		if( count( $subProductIds ) === 0 ) {
412
+		if (count($subProductIds) === 0) {
413 413
 			return array();
414 414
 		}
415 415
 
416
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
417
-		$search = $productManager->createSearch( true );
416
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
417
+		$search = $productManager->createSearch(true);
418 418
 
419 419
 		$expr = array(
420
-				$search->compare( '==', 'product.id', $subProductIds ),
420
+				$search->compare('==', 'product.id', $subProductIds),
421 421
 				$search->getConditions(),
422 422
 		);
423 423
 
424
-		if( count( $variantAttributeIds ) > 0 )
424
+		if (count($variantAttributeIds) > 0)
425 425
 		{
426
-			foreach( $variantAttributeIds as $key => $id ) {
426
+			foreach ($variantAttributeIds as $key => $id) {
427 427
 				$variantAttributeIds[$key] = (string) $id;
428 428
 			}
429 429
 
430
-			$listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' );
430
+			$listTypeItem = $this->getProductListTypeItem('attribute', 'variant');
431 431
 
432
-			$param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds );
433
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
432
+			$param = array('attribute', $listTypeItem->getId(), $variantAttributeIds);
433
+			$cmpfunc = $search->createFunction('product.contains', $param);
434 434
 
435
-			$expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) );
435
+			$expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds));
436 436
 		}
437 437
 
438
-		$search->setConditions( $search->combine( '&&', $expr ) );
438
+		$search->setConditions($search->combine('&&', $expr));
439 439
 
440
-		return $productManager->searchItems( $search, $domains );
440
+		return $productManager->searchItems($search, $domains);
441 441
 	}
442 442
 
443 443
 
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 	 * @param mixed $default Default value if no value is available for the given name
450 450
 	 * @return mixed Value from the array or default value
451 451
 	 */
452
-	protected function getValue( array $values, $name, $default = null )
452
+	protected function getValue(array $values, $name, $default = null)
453 453
 	{
454
-		if( isset( $values[$name] ) ) {
454
+		if (isset($values[$name])) {
455 455
 			return $values[$name];
456 456
 		}
457 457
 
@@ -466,24 +466,24 @@  discard block
 block discarded – undo
466 466
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If product is not associated to at least one category
467 467
 	 * @deprecated 2016.05
468 468
 	 */
469
-	protected function checkCategory( $prodid )
469
+	protected function checkCategory($prodid)
470 470
 	{
471
-		$catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
471
+		$catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
472 472
 
473
-		$search = $catalogListManager->createSearch( true );
473
+		$search = $catalogListManager->createSearch(true);
474 474
 		$expr = array(
475
-				$search->compare( '==', 'catalog.lists.refid', $prodid ),
475
+				$search->compare('==', 'catalog.lists.refid', $prodid),
476 476
 				$search->getConditions()
477 477
 		);
478
-		$search->setConditions( $search->combine( '&&', $expr ) );
479
-		$search->setSlice( 0, 1 );
478
+		$search->setConditions($search->combine('&&', $expr));
479
+		$search->setSlice(0, 1);
480 480
 
481
-		$result = $catalogListManager->searchItems( $search );
481
+		$result = $catalogListManager->searchItems($search);
482 482
 
483
-		if( reset( $result ) === false )
483
+		if (reset($result) === false)
484 484
 		{
485
-			$msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid );
486
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
485
+			$msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid);
486
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
487 487
 		}
488 488
 	}
489 489
 
@@ -495,35 +495,35 @@  discard block
 block discarded – undo
495 495
 	 * @param string $warehouse Unique code of the warehouse
496 496
 	 * @return integer|null Number of available items in stock (null for unlimited stock)
497 497
 	 */
498
-	protected function getStockLevel( $prodid, $warehouse )
498
+	protected function getStockLevel($prodid, $warehouse)
499 499
 	{
500
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' );
500
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock');
501 501
 
502
-		$search = $manager->createSearch( true );
502
+		$search = $manager->createSearch(true);
503 503
 		$expr = array(
504
-				$search->compare( '==', 'product.stock.parentid', $prodid ),
504
+				$search->compare('==', 'product.stock.parentid', $prodid),
505 505
 				$search->getConditions(),
506
-				$search->compare( '==', 'product.stock.warehouse.code', $warehouse ),
506
+				$search->compare('==', 'product.stock.warehouse.code', $warehouse),
507 507
 		);
508
-		$search->setConditions( $search->combine( '&&', $expr ) );
508
+		$search->setConditions($search->combine('&&', $expr));
509 509
 
510
-		$result = $manager->searchItems( $search );
510
+		$result = $manager->searchItems($search);
511 511
 
512
-		if( empty( $result ) )
512
+		if (empty($result))
513 513
 		{
514
-			$msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse );
515
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
514
+			$msg = sprintf('No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse);
515
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
516 516
 		}
517 517
 
518 518
 		$stocklevel = null;
519 519
 
520
-		foreach( $result as $item )
520
+		foreach ($result as $item)
521 521
 		{
522
-			if( ( $stock = $item->getStockLevel() ) === null ) {
522
+			if (($stock = $item->getStockLevel()) === null) {
523 523
 				return null;
524 524
 			}
525 525
 
526
-			$stocklevel = max( (int) $stocklevel, $item->getStockLevel() );
526
+			$stocklevel = max((int) $stocklevel, $item->getStockLevel());
527 527
 		}
528 528
 
529 529
 		return $stocklevel;
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Order/Decorator/Base.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -29,9 +29,9 @@  discard block
 block discarded – undo
29 29
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object to be stored
30 30
 	 * @return \Aimeos\MShop\Order\Item\Iface Order item that belongs to the stored basket
31 31
 	 */
32
-	public function store( \Aimeos\MShop\Order\Item\Base\Iface $basket )
32
+	public function store(\Aimeos\MShop\Order\Item\Base\Iface $basket)
33 33
 	{
34
-		$this->getController()->store( $basket );
34
+		$this->getController()->store($basket);
35 35
 	}
36 36
 
37 37
 
@@ -54,9 +54,9 @@  discard block
 block discarded – undo
54 54
 	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
55 55
 	 * @return void
56 56
 	 */
57
-	public function block( \Aimeos\MShop\Order\Item\Iface $orderItem )
57
+	public function block(\Aimeos\MShop\Order\Item\Iface $orderItem)
58 58
 	{
59
-		$this->getController()->block( $orderItem );
59
+		$this->getController()->block($orderItem);
60 60
 	}
61 61
 
62 62
 
@@ -79,9 +79,9 @@  discard block
 block discarded – undo
79 79
 	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
80 80
 	 * @return void
81 81
 	 */
82
-	public function unblock( \Aimeos\MShop\Order\Item\Iface $orderItem )
82
+	public function unblock(\Aimeos\MShop\Order\Item\Iface $orderItem)
83 83
 	{
84
-		$this->getController()->unblock( $orderItem );
84
+		$this->getController()->unblock($orderItem);
85 85
 	}
86 86
 
87 87
 
@@ -100,8 +100,8 @@  discard block
 block discarded – undo
100 100
 	 * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object
101 101
 	 * @return void
102 102
 	 */
103
-	public function update( \Aimeos\MShop\Order\Item\Iface $orderItem );
103
+	public function update(\Aimeos\MShop\Order\Item\Iface $orderItem);
104 104
 	{
105
-		$this->getController()->update( $orderItem );
105
+		$this->getController()->update($orderItem);
106 106
 	}
107 107
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Service/Decorator/Base.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 	 * @param array $ref List of domains for which the items referenced by the services should be fetched too
28 28
 	 * @return array List of service items implementing \Aimeos\MShop\Service\Item\Iface with referenced items
29 29
 	 */
30
-	public function getServices( $type, \Aimeos\MShop\Order\Item\Base\Iface $basket,
31
-		$ref = array( 'media', 'price', 'text' ) )
30
+	public function getServices($type, \Aimeos\MShop\Order\Item\Base\Iface $basket,
31
+		$ref = array('media', 'price', 'text'))
32 32
 	{
33
-		$this->getController()->getServices( $type, $basket, $ref );
33
+		$this->getController()->getServices($type, $basket, $ref);
34 34
 	}
35 35
 
36 36
 
@@ -43,9 +43,9 @@  discard block
 block discarded – undo
43 43
 	 * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object
44 44
 	 * @return array List of attribute definitions implementing \Aimeos\MW\Criteria\Attribute\Iface
45 45
 	 */
46
-	public function getServiceAttributes( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket )
46
+	public function getServiceAttributes($type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket)
47 47
 	{
48
-		$this->getController()->getServiceAttributes( $type, $serviceId, $basket );
48
+		$this->getController()->getServiceAttributes($type, $serviceId, $basket);
49 49
 	}
50 50
 
51 51
 
@@ -60,9 +60,9 @@  discard block
 block discarded – undo
60 60
 	 * @throws \Aimeos\MShop\Exception If service provider isn't available
61 61
 	 * @throws \Exception If an error occurs
62 62
 	 */
63
-	public function getServicePrice( $type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket )
63
+	public function getServicePrice($type, $serviceId, \Aimeos\MShop\Order\Item\Base\Iface $basket)
64 64
 	{
65
-		$this->getController()->getServicePrice( $type, $serviceId, $basket );
65
+		$this->getController()->getServicePrice($type, $serviceId, $basket);
66 66
 	}
67 67
 
68 68
 
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 * @return array List of key/value pairs of attributes keys and an error message for values that are invalid or
77 77
 	 * 	missing
78 78
 	 */
79
-	public function checkServiceAttributes( $type, $serviceId, array $attributes )
79
+	public function checkServiceAttributes($type, $serviceId, array $attributes)
80 80
 	{
81
-		$this->getController()->checkServiceAttributes( $type, $serviceId, $attributes );
81
+		$this->getController()->checkServiceAttributes($type, $serviceId, $attributes);
82 82
 	}
83 83
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Catalog/Decorator/Base.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
 	 * @param string $name Name of the manager
26 26
 	 * @return \Aimeos\MShop\Common\Manager\Iface Manager object
27 27
 	 */
28
-	public function createManager( $name )
28
+	public function createManager($name)
29 29
 	{
30
-		return $this->getController()->createManager( $name );
30
+		return $this->getController()->createManager($name);
31 31
 	}
32 32
 
33 33
 
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	 * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys
53 53
 	 * @since 2015.08
54 54
 	 */
55
-	public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) )
55
+	public function getCatalogPath($id, array $domains = array('text', 'media'))
56 56
 	{
57
-		return $this->getController()->getCatalogPath( $id, $domains );
57
+		return $this->getController()->getCatalogPath($id, $domains);
58 58
 	}
59 59
 
60 60
 
@@ -69,10 +69,10 @@  discard block
 block discarded – undo
69 69
 	 * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant
70 70
 	 * @since 2015.08
71 71
 	 */
72
-	public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ),
73
-		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null )
72
+	public function getCatalogTree($id = null, array $domains = array('text', 'media'),
73
+		$level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null)
74 74
 	{
75
-		return $this->getController()->getCatalogTree( $id, $domains, $level, $search );
75
+		return $this->getController()->getCatalogTree($id, $domains, $level, $search);
76 76
 	}
77 77
 
78 78
 
@@ -84,9 +84,9 @@  discard block
 block discarded – undo
84 84
 	 * @return array Associative list of key values as key and the product count for this key as value
85 85
 	 * @since 2015.08
86 86
 	 */
87
-	public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key )
87
+	public function aggregateIndex(\Aimeos\MW\Criteria\Iface $filter, $key)
88 88
 	{
89
-		return $this->getController()->aggregateIndex( $filter, $key );
89
+		return $this->getController()->aggregateIndex($filter, $key);
90 90
 	}
91 91
 
92 92
 
@@ -98,9 +98,9 @@  discard block
 block discarded – undo
98 98
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
99 99
 	 * @since 2015.08
100 100
 	 */
101
-	public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid )
101
+	public function addIndexFilterCategory(\Aimeos\MW\Criteria\Iface $search, $catid)
102 102
 	{
103
-		return $this->getController()->addIndexFilterCategory( $search, $catid );
103
+		return $this->getController()->addIndexFilterCategory($search, $catid);
104 104
 	}
105 105
 
106 106
 
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
114 114
 	 * @since 2015.08
115 115
 	 */
116
-	public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' )
116
+	public function addIndexFilterText(\Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default')
117 117
 	{
118
-		return $this->getController()->addIndexFilterText( $search, $input, $listtype );
118
+		return $this->getController()->addIndexFilterText($search, $input, $listtype);
119 119
 	}
120 120
 
121 121
 
@@ -130,9 +130,9 @@  discard block
 block discarded – undo
130 130
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
131 131
 	 * @since 2015.08
132 132
 	 */
133
-	public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' )
133
+	public function createIndexFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default')
134 134
 	{
135
-		return $this->getController()->createIndexFilter( $sort, $direction, $start, $size, $listtype );
135
+		return $this->getController()->createIndexFilter($sort, $direction, $start, $size, $listtype);
136 136
 	}
137 137
 
138 138
 
@@ -148,9 +148,9 @@  discard block
 block discarded – undo
148 148
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
149 149
 	 * @since 2015.08
150 150
 	 */
151
-	public function createIndexFilterCategory( $catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' )
151
+	public function createIndexFilterCategory($catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default')
152 152
 	{
153
-		return $this->getController()->createIndexFilter( $catid, $sort, $direction, $start, $size, $listtype );
153
+		return $this->getController()->createIndexFilter($catid, $sort, $direction, $start, $size, $listtype);
154 154
 	}
155 155
 
156 156
 
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
167 167
 	 * @since 2015.08
168 168
 	 */
169
-	public function createIndexFilterText( $input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' )
169
+	public function createIndexFilterText($input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default')
170 170
 	{
171
-		return $this->getController()->createIndexFilter( $input, $sort, $direction, $start, $size, $listtype );
171
+		return $this->getController()->createIndexFilter($input, $sort, $direction, $start, $size, $listtype);
172 172
 	}
173 173
 
174 174
 
@@ -181,9 +181,9 @@  discard block
 block discarded – undo
181 181
 	 * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface
182 182
 	 * @since 2015.08
183 183
 	 */
184
-	public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null )
184
+	public function getIndexItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null)
185 185
 	{
186
-		return $this->getController()->getIndexItems( $filter, $domains, $total );
186
+		return $this->getController()->getIndexItems($filter, $domains, $total);
187 187
 	}
188 188
 
189 189
 
@@ -195,9 +195,9 @@  discard block
 block discarded – undo
195 195
 	 * @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface
196 196
 	 * @since 2015.08
197 197
 	 */
198
-	public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) )
198
+	public function getProductItems(array $ids, array $domains = array('media', 'price', 'text'))
199 199
 	{
200
-		return $this->getController()->getProductItems( $ids, $domains );
200
+		return $this->getController()->getProductItems($ids, $domains);
201 201
 	}
202 202
 
203 203
 
@@ -213,9 +213,9 @@  discard block
 block discarded – undo
213 213
 	 * @param string $type Type of the text like "name", "short", "long", etc.
214 214
 	 * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching
215 215
 	 */
216
-	public function createTextFilter( $input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name' )
216
+	public function createTextFilter($input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name')
217 217
 	{
218
-		return $this->getController()->createTextFilter( $input, $sort, $direction, $start, $size, $listtype, $type );
218
+		return $this->getController()->createTextFilter($input, $sort, $direction, $start, $size, $listtype, $type);
219 219
 	}
220 220
 
221 221
 
@@ -225,8 +225,8 @@  discard block
 block discarded – undo
225 225
 	 * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions
226 226
 	 * @return array Associative list of the product ID as key and the product text as value
227 227
 	 */
228
-	public function getTextList( \Aimeos\MW\Criteria\Iface $filter )
228
+	public function getTextList(\Aimeos\MW\Criteria\Iface $filter)
229 229
 	{
230
-		return $this->getController()->getTextList( $filter );
230
+		return $this->getController()->getTextList($filter);
231 231
 	}
232 232
 }
Please login to merge, or discard this patch.