Completed
Push — master ( 35bd2a...cd55f0 )
by Aimeos
02:14
created
controller/frontend/src/Controller/Frontend/Basket/Standard.php 2 patches
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases
34 34
 	 *  connections, logger, session, etc.
35 35
 	 */
36
-	public function __construct( \Aimeos\MShop\Context\Item\Iface $context )
36
+	public function __construct(\Aimeos\MShop\Context\Item\Iface $context)
37 37
 	{
38
-		parent::__construct( $context );
38
+		parent::__construct($context);
39 39
 
40
-		$this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' );
40
+		$this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base');
41 41
 	}
42 42
 
43 43
 
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 	public function clear()
50 50
 	{
51 51
 		$this->baskets[$this->type] = $this->domainManager->createItem();
52
-		$this->domainManager->setSession( $this->baskets[$this->type], $this->type );
52
+		$this->domainManager->setSession($this->baskets[$this->type], $this->type);
53 53
 
54 54
 		return $this;
55 55
 	}
@@ -62,10 +62,10 @@  discard block
 block discarded – undo
62 62
 	 */
63 63
 	public function get()
64 64
 	{
65
-		if( !isset( $this->baskets[$this->type] ) )
65
+		if (!isset($this->baskets[$this->type]))
66 66
 		{
67
-			$this->baskets[$this->type] = $this->domainManager->getSession( $this->type );
68
-			$this->checkLocale( $this->type );
67
+			$this->baskets[$this->type] = $this->domainManager->getSession($this->type);
68
+			$this->checkLocale($this->type);
69 69
 		}
70 70
 
71 71
 		return $this->baskets[$this->type];
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
 	 */
80 80
 	public function save()
81 81
 	{
82
-		if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) {
83
-			$this->domainManager->setSession( $this->baskets[$this->type], $this->type );
82
+		if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) {
83
+			$this->domainManager->setSession($this->baskets[$this->type], $this->type);
84 84
 		}
85 85
 
86 86
 		return $this;
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 	 * @param string $type Basket type
94 94
 	 * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object
95 95
 	 */
96
-	public function setType( $type )
96
+	public function setType($type)
97 97
 	{
98 98
 		$this->type = $type;
99 99
 		return $this;
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 		 * @category Developer
128 128
 		 * @see controller/frontend/basket/limit-seconds
129 129
 		 */
130
-		$count = $config->get( 'controller/frontend/basket/limit-count', 5 );
130
+		$count = $config->get('controller/frontend/basket/limit-count', 5);
131 131
 
132 132
 		/** controller/frontend/basket/limit-seconds
133 133
 		 * Order limitation time frame in seconds
@@ -145,30 +145,30 @@  discard block
 block discarded – undo
145 145
 		 * @category Developer
146 146
 		 * @see controller/frontend/basket/limit-count
147 147
 		 */
148
-		$seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 );
148
+		$seconds = $config->get('controller/frontend/basket/limit-seconds', 300);
149 149
 
150 150
 		$search = $this->domainManager->createSearch();
151 151
 		$expr = [
152
-			$search->compare( '==', 'order.base.editor', $context->getEditor() ),
153
-			$search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ),
152
+			$search->compare('==', 'order.base.editor', $context->getEditor()),
153
+			$search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)),
154 154
 		];
155
-		$search->setConditions( $search->combine( '&&', $expr ) );
156
-		$search->setSlice( 0, 0 );
155
+		$search->setConditions($search->combine('&&', $expr));
156
+		$search->setSlice(0, 0);
157 157
 
158
-		$this->domainManager->searchItems( $search, [], $total );
158
+		$this->domainManager->searchItems($search, [], $total);
159 159
 
160
-		if( $total > $count )
160
+		if ($total > $count)
161 161
 		{
162
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Temporary order limit reached' );
163
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
162
+			$msg = $context->getI18n()->dt('controller/frontend', 'Temporary order limit reached');
163
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
164 164
 		}
165 165
 
166 166
 
167 167
 		$basket = $this->get()->finish();
168
-		$basket->setCustomerId( (string) $context->getUserId() );
168
+		$basket->setCustomerId((string) $context->getUserId());
169 169
 
170 170
 		$this->domainManager->begin();
171
-		$this->domainManager->store( $basket );
171
+		$this->domainManager->store($basket);
172 172
 		$this->domainManager->commit();
173 173
 
174 174
 		return $basket;
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
 	 * @param boolean $default True to add default criteria (user logged in), false if not
184 184
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts
185 185
 	 */
186
-	public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true )
186
+	public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true)
187 187
 	{
188
-		return $this->domainManager->load( $id, $parts, false, $default );
188
+		return $this->domainManager->load($id, $parts, false, $default);
189 189
 	}
190 190
 
191 191
 
@@ -205,34 +205,34 @@  discard block
 block discarded – undo
205 205
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
206 206
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
207 207
 	 */
208
-	public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [],
208
+	public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [],
209 209
 		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [],
210
-		$stocktype = 'default' )
210
+		$stocktype = 'default')
211 211
 	{
212 212
 		$attributeMap = [
213
-			'custom' => array_keys( $customAttributeValues ),
213
+			'custom' => array_keys($customAttributeValues),
214 214
 			'config' => $configAttributeIds,
215 215
 			'hidden' => $hiddenAttributeIds,
216 216
 		];
217
-		$this->checkListRef( $prodid, 'attribute', $attributeMap );
217
+		$this->checkListRef($prodid, 'attribute', $attributeMap);
218 218
 
219 219
 
220 220
 		$context = $this->getContext();
221
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
222
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true );
223
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
221
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
222
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true);
223
+		$prices = $productItem->getRefItems('price', 'default', 'default');
224 224
 
225
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
226
-		$orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype );
225
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
226
+		$orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype);
227 227
 
228
-		$attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues );
229
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) );
230
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) );
228
+		$attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues);
229
+		$attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds));
230
+		$attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds));
231 231
 
232
-		$orderBaseProductItem->setAttributes( $attr );
233
-		$orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) );
232
+		$orderBaseProductItem->setAttributes($attr);
233
+		$orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity));
234 234
 
235
-		$this->get()->addProduct( $orderBaseProductItem );
235
+		$this->get()->addProduct($orderBaseProductItem);
236 236
 		$this->save();
237 237
 	}
238 238
 
@@ -242,17 +242,17 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @param integer $position Position number (key) of the order product item
244 244
 	 */
245
-	public function deleteProduct( $position )
245
+	public function deleteProduct($position)
246 246
 	{
247
-		$product = $this->get()->getProduct( $position );
247
+		$product = $this->get()->getProduct($position);
248 248
 
249
-		if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
249
+		if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE)
250 250
 		{
251
-			$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually' );
252
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) );
251
+			$msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be deleted manually');
252
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position));
253 253
 		}
254 254
 
255
-		$this->get()->deleteProduct( $position );
255
+		$this->get()->deleteProduct($position);
256 256
 		$this->save();
257 257
 	}
258 258
 
@@ -266,33 +266,33 @@  discard block
 block discarded – undo
266 266
 	 * 	The 'stock'=>false option allows adding products without being in stock.
267 267
 	 * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED
268 268
 	 */
269
-	public function editProduct( $position, $quantity, array $options = [],
270
-		array $configAttributeCodes = [] )
269
+	public function editProduct($position, $quantity, array $options = [],
270
+		array $configAttributeCodes = [])
271 271
 	{
272
-		$product = $this->get()->getProduct( $position );
272
+		$product = $this->get()->getProduct($position);
273 273
 
274
-		if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE )
274
+		if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE)
275 275
 		{
276
-			$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Basket item at position "%1$d" cannot be changed' );
277
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $position ) );
276
+			$msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Basket item at position "%1$d" cannot be changed');
277
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $position));
278 278
 		}
279 279
 
280
-		$product->setQuantity( $quantity );
280
+		$product->setQuantity($quantity);
281 281
 
282 282
 		$attributes = $product->getAttributes();
283
-		foreach( $attributes as $key => $attribute )
283
+		foreach ($attributes as $key => $attribute)
284 284
 		{
285
-			if( in_array( $attribute->getCode(), $configAttributeCodes ) ) {
286
-				unset( $attributes[$key] );
285
+			if (in_array($attribute->getCode(), $configAttributeCodes)) {
286
+				unset($attributes[$key]);
287 287
 			}
288 288
 		}
289
-		$product->setAttributes( $attributes );
289
+		$product->setAttributes($attributes);
290 290
 
291
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
292
-		$productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ) );
293
-		$product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) );
291
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
292
+		$productItem = $manager->findItem($product->getProductCode(), array('price', 'text'));
293
+		$product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity));
294 294
 
295
-		$this->get()->editProduct( $product, $position );
295
+		$this->get()->editProduct($product, $position);
296 296
 
297 297
 		$this->save();
298 298
 	}
@@ -304,7 +304,7 @@  discard block
 block discarded – undo
304 304
 	 * @param string $code Coupon code entered by the user
305 305
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
306 306
 	 */
307
-	public function addCoupon( $code )
307
+	public function addCoupon($code)
308 308
 	{
309 309
 		$context = $this->getContext();
310 310
 
@@ -324,63 +324,63 @@  discard block
 block discarded – undo
324 324
 		 * @category User
325 325
 		 * @category Developer
326 326
 		 */
327
-		$allowed = $context->getConfig()->get( 'client/html/basket/standard/coupon/allowed', 1 ); // @deprecated
328
-		$allowed = $context->getConfig()->get( 'controller/frontend/basket/standard/coupon/allowed', $allowed );
327
+		$allowed = $context->getConfig()->get('client/html/basket/standard/coupon/allowed', 1); // @deprecated
328
+		$allowed = $context->getConfig()->get('controller/frontend/basket/standard/coupon/allowed', $allowed);
329 329
 
330
-		if( $allowed <= count( $this->get()->getCoupons() ) )
330
+		if ($allowed <= count($this->get()->getCoupons()))
331 331
 		{
332
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Number of coupon codes exceeds the limit' );
333
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
332
+			$msg = $context->getI18n()->dt('controller/frontend', 'Number of coupon codes exceeds the limit');
333
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
334 334
 		}
335 335
 
336 336
 
337
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' );
338
-		$codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' );
337
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon');
338
+		$codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code');
339 339
 
340 340
 
341
-		$search = $codeManager->createSearch( true );
341
+		$search = $codeManager->createSearch(true);
342 342
 		$expr = array(
343
-			$search->compare( '==', 'coupon.code.code', $code ),
343
+			$search->compare('==', 'coupon.code.code', $code),
344 344
 			$search->getConditions(),
345 345
 		);
346
-		$search->setConditions( $search->combine( '&&', $expr ) );
347
-		$search->setSlice( 0, 1 );
346
+		$search->setConditions($search->combine('&&', $expr));
347
+		$search->setSlice(0, 1);
348 348
 
349
-		$result = $codeManager->searchItems( $search );
349
+		$result = $codeManager->searchItems($search);
350 350
 
351
-		if( ( $codeItem = reset( $result ) ) === false )
351
+		if (($codeItem = reset($result)) === false)
352 352
 		{
353
-			$msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid or not available any more' ), $code );
354
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
353
+			$msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid or not available any more'), $code);
354
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
355 355
 		}
356 356
 
357 357
 
358
-		$search = $manager->createSearch( true );
358
+		$search = $manager->createSearch(true);
359 359
 		$expr = array(
360
-			$search->compare( '==', 'coupon.id', $codeItem->getParentId() ),
360
+			$search->compare('==', 'coupon.id', $codeItem->getParentId()),
361 361
 			$search->getConditions(),
362 362
 		);
363
-		$search->setConditions( $search->combine( '&&', $expr ) );
364
-		$search->setSlice( 0, 1 );
363
+		$search->setConditions($search->combine('&&', $expr));
364
+		$search->setSlice(0, 1);
365 365
 
366
-		$result = $manager->searchItems( $search );
366
+		$result = $manager->searchItems($search);
367 367
 
368
-		if( ( $item = reset( $result ) ) === false )
368
+		if (($item = reset($result)) === false)
369 369
 		{
370
-			$msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Coupon for code "%1$s" is not available any more' ), $code );
371
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
370
+			$msg = sprintf($context->getI18n()->dt('controller/frontend', 'Coupon for code "%1$s" is not available any more'), $code);
371
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
372 372
 		}
373 373
 
374 374
 
375
-		$provider = $manager->getProvider( $item, $codeItem->getCode() );
375
+		$provider = $manager->getProvider($item, $codeItem->getCode());
376 376
 
377
-		if( $provider->isAvailable( $this->get() ) !== true )
377
+		if ($provider->isAvailable($this->get()) !== true)
378 378
 		{
379
-			$msg = sprintf( $context->getI18n()->dt( 'controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met' ), $code );
380
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
379
+			$msg = sprintf($context->getI18n()->dt('controller/frontend', 'Requirements for coupon code "%1$s" aren\'t met'), $code);
380
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
381 381
 		}
382 382
 
383
-		$provider->addCoupon( $this->get() );
383
+		$provider->addCoupon($this->get());
384 384
 		$this->save();
385 385
 	}
386 386
 
@@ -391,24 +391,24 @@  discard block
 block discarded – undo
391 391
 	 * @param string $code Coupon code entered by the user
392 392
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
393 393
 	 */
394
-	public function deleteCoupon( $code )
394
+	public function deleteCoupon($code)
395 395
 	{
396 396
 		$context = $this->getContext();
397
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'coupon' );
397
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'coupon');
398 398
 
399 399
 		$search = $manager->createSearch();
400
-		$search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) );
401
-		$search->setSlice( 0, 1 );
400
+		$search->setConditions($search->compare('==', 'coupon.code.code', $code));
401
+		$search->setSlice(0, 1);
402 402
 
403
-		$result = $manager->searchItems( $search );
403
+		$result = $manager->searchItems($search);
404 404
 
405
-		if( ( $item = reset( $result ) ) === false )
405
+		if (($item = reset($result)) === false)
406 406
 		{
407
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Coupon code "%1$s" is invalid' );
408
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $code ) );
407
+			$msg = $context->getI18n()->dt('controller/frontend', 'Coupon code "%1$s" is invalid');
408
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $code));
409 409
 		}
410 410
 
411
-		$manager->getProvider( $item, $code )->deleteCoupon( $this->get() );
411
+		$manager->getProvider($item, $code)->deleteCoupon($this->get());
412 412
 		$this->save();
413 413
 	}
414 414
 
@@ -421,30 +421,30 @@  discard block
 block discarded – undo
421 421
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of
422 422
 	 * 	if one of the keys is invalid when using an array with key/value pairs
423 423
 	 */
424
-	public function setAddress( $type, $value )
424
+	public function setAddress($type, $value)
425 425
 	{
426 426
 		$context = $this->getContext();
427
-		$address = \Aimeos\MShop\Factory::createManager( $context, 'order/base/address' )->createItem();
428
-		$address->setType( $type );
427
+		$address = \Aimeos\MShop\Factory::createManager($context, 'order/base/address')->createItem();
428
+		$address->setType($type);
429 429
 
430
-		if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface )
430
+		if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface)
431 431
 		{
432
-			$address->copyFrom( $value );
433
-			$this->get()->setAddress( $address, $type );
432
+			$address->copyFrom($value);
433
+			$this->get()->setAddress($address, $type);
434 434
 		}
435
-		else if( is_array( $value ) )
435
+		else if (is_array($value))
436 436
 		{
437
-			$this->setAddressFromArray( $address, $value );
438
-			$this->get()->setAddress( $address, $type );
437
+			$this->setAddressFromArray($address, $value);
438
+			$this->get()->setAddress($address, $type);
439 439
 		}
440
-		else if( $value === null )
440
+		else if ($value === null)
441 441
 		{
442
-			$this->get()->deleteAddress( $type );
442
+			$this->get()->deleteAddress($type);
443 443
 		}
444 444
 		else
445 445
 		{
446
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' );
447
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) );
446
+			$msg = $context->getI18n()->dt('controller/frontend', 'Invalid value for address type "%1$s"');
447
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $type));
448 448
 		}
449 449
 
450 450
 		$this->save();
@@ -460,49 +460,49 @@  discard block
 block discarded – undo
460 460
 	 * 	entered by the customer when choosing one of the delivery or payment options
461 461
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
462 462
 	 */
463
-	public function setService( $type, $id, array $attributes = [] )
463
+	public function setService($type, $id, array $attributes = [])
464 464
 	{
465
-		if( $id === null )
465
+		if ($id === null)
466 466
 		{
467
-			$this->get()->deleteService( $type );
467
+			$this->get()->deleteService($type);
468 468
 			$this->save();
469 469
 			return;
470 470
 		}
471 471
 
472 472
 		$context = $this->getContext();
473 473
 
474
-		$serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' );
475
-		$serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) );
474
+		$serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service');
475
+		$serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text'));
476 476
 
477
-		$provider = $serviceManager->getProvider( $serviceItem );
478
-		$result = $provider->checkConfigFE( $attributes );
479
-		$unknown = array_diff_key( $attributes, $result );
477
+		$provider = $serviceManager->getProvider($serviceItem);
478
+		$result = $provider->checkConfigFE($attributes);
479
+		$unknown = array_diff_key($attributes, $result);
480 480
 
481
-		if( count( $unknown ) > 0 )
481
+		if (count($unknown) > 0)
482 482
 		{
483
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Unknown attributes "%1$s"' );
484
-			$msg = sprintf( $msg, implode( '","', array_keys( $unknown ) ) );
485
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
483
+			$msg = $context->getI18n()->dt('controller/frontend', 'Unknown attributes "%1$s"');
484
+			$msg = sprintf($msg, implode('","', array_keys($unknown)));
485
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
486 486
 		}
487 487
 
488
-		foreach( $result as $key => $value )
488
+		foreach ($result as $key => $value)
489 489
 		{
490
-			if( $value !== null ) {
491
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( $value );
490
+			if ($value !== null) {
491
+				throw new \Aimeos\Controller\Frontend\Basket\Exception($value);
492 492
 			}
493 493
 		}
494 494
 
495
-		$orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' );
495
+		$orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service');
496 496
 		$orderServiceItem = $orderBaseServiceManager->createItem();
497
-		$orderServiceItem->copyFrom( $serviceItem );
497
+		$orderServiceItem->copyFrom($serviceItem);
498 498
 
499 499
 		// remove service rebate of original price
500
-		$price = $provider->calcPrice( $this->get() )->setRebate( '0.00' );
501
-		$orderServiceItem->setPrice( $price );
500
+		$price = $provider->calcPrice($this->get())->setRebate('0.00');
501
+		$orderServiceItem->setPrice($price);
502 502
 
503
-		$provider->setConfigFE( $orderServiceItem, $attributes );
503
+		$provider->setConfigFE($orderServiceItem, $attributes);
504 504
 
505
-		$this->get()->setService( $orderServiceItem, $type );
505
+		$this->get()->setService($orderServiceItem, $type);
506 506
 		$this->save();
507 507
 	}
508 508
 
@@ -515,18 +515,18 @@  discard block
 block discarded – undo
515 515
 	 * 	an address item.
516 516
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
517 517
 	 */
518
-	protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map )
518
+	protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map)
519 519
 	{
520
-		foreach( $map as $key => $value ) {
521
-			$map[$key] = strip_tags( $value ); // prevent XSS
520
+		foreach ($map as $key => $value) {
521
+			$map[$key] = strip_tags($value); // prevent XSS
522 522
 		}
523 523
 
524
-		$errors = $address->fromArray( $map );
524
+		$errors = $address->fromArray($map);
525 525
 
526
-		if( count( $errors ) > 0 )
526
+		if (count($errors) > 0)
527 527
 		{
528
-			$msg = $this->getContext()->getI18n()->dt( 'controller/frontend', 'Invalid address properties, please check your input' );
529
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors );
528
+			$msg = $this->getContext()->getI18n()->dt('controller/frontend', 'Invalid address properties, please check your input');
529
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors);
530 530
 		}
531 531
 	}
532 532
 }
Please login to merge, or discard this patch.
Braces   +3 added lines, -6 removed lines patch added patch discarded remove patch
@@ -431,17 +431,14 @@
 block discarded – undo
431 431
 		{
432 432
 			$address->copyFrom( $value );
433 433
 			$this->get()->setAddress( $address, $type );
434
-		}
435
-		else if( is_array( $value ) )
434
+		} else if( is_array( $value ) )
436 435
 		{
437 436
 			$this->setAddressFromArray( $address, $value );
438 437
 			$this->get()->setAddress( $address, $type );
439
-		}
440
-		else if( $value === null )
438
+		} else if( $value === null )
441 439
 		{
442 440
 			$this->get()->deleteAddress( $type );
443
-		}
444
-		else
441
+		} else
445 442
 		{
446 443
 			$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid value for address type "%1$s"' );
447 444
 			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $type ) );
Please login to merge, or discard this patch.