Completed
Push — master ( 2fc608...167152 )
by Aimeos
01:59
created
controller/frontend/src/Controller/Frontend/Basket/Decorator/Bundle.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -36,13 +36,13 @@  discard block
 block discarded – undo
36 36
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
37 37
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
38 38
 	 */
39
-	public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
40
-		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] )
39
+	public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
40
+		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [])
41 41
 	{
42 42
 		$context = $this->getContext();
43
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
43
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
44 44
 
45
-		if( $productManager->getItem( $prodid, [], true )->getType() !== 'bundle' )
45
+		if ($productManager->getItem($prodid, [], true)->getType() !== 'bundle')
46 46
 		{
47 47
 			return $this->getController()->addProduct(
48 48
 				$prodid, $quantity, $stocktype, $variantAttributeIds,
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 		}
52 52
 
53 53
 		$attributeMap = [
54
-			'custom' => array_keys( $customAttributeValues ),
55
-			'config' => array_keys( $configAttributeIds ),
54
+			'custom' => array_keys($customAttributeValues),
55
+			'config' => array_keys($configAttributeIds),
56 56
 			'hidden' => $hiddenAttributeIds,
57 57
 		];
58
-		$this->checkListRef( $prodid, 'attribute', $attributeMap );
58
+		$this->checkListRef($prodid, 'attribute', $attributeMap);
59 59
 
60 60
 
61
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true );
62
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
61
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true);
62
+		$prices = $productItem->getRefItems('price', 'default', 'default');
63 63
 
64
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
65
-		$orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype );
64
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
65
+		$orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype);
66 66
 
67
-		$this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype );
67
+		$this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype);
68 68
 
69
-		$attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues );
70
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) );
71
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) );
69
+		$attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues);
70
+		$attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds));
71
+		$attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds));
72 72
 
73
-		$orderBaseProductItem->setAttributes( $attr );
74
-		$orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) );
73
+		$orderBaseProductItem->setAttributes($attr);
74
+		$orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity));
75 75
 
76
-		$this->getController()->get()->addProduct( $orderBaseProductItem );
76
+		$this->getController()->get()->addProduct($orderBaseProductItem);
77 77
 		$this->getController()->save();
78 78
 	}
79 79
 
@@ -86,43 +86,43 @@  discard block
 block discarded – undo
86 86
 	 * @param array $variantAttributeIds List of product variant attribute IDs
87 87
 	 * @param string $stocktype
88 88
 	 */
89
-	protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
90
-		\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype )
89
+	protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
90
+		\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype)
91 91
 	{
92 92
 		$quantity = $orderBaseProductItem->getQuantity();
93 93
 		$products = $subProductIds = $orderProducts = [];
94
-		$orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' );
94
+		$orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product');
95 95
 
96
-		foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) {
96
+		foreach ($productItem->getRefItems('product', null, 'default') as $item) {
97 97
 			$subProductIds[] = $item->getId();
98 98
 		}
99 99
 
100
-		if( count( $subProductIds ) > 0 )
100
+		if (count($subProductIds) > 0)
101 101
 		{
102
-			$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
102
+			$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
103 103
 
104
-			$search = $productManager->createSearch( true );
104
+			$search = $productManager->createSearch(true);
105 105
 			$expr = array(
106
-				$search->compare( '==', 'product.id', $subProductIds ),
106
+				$search->compare('==', 'product.id', $subProductIds),
107 107
 				$search->getConditions(),
108 108
 			);
109
-			$search->setConditions( $search->combine( '&&', $expr ) );
109
+			$search->setConditions($search->combine('&&', $expr));
110 110
 
111
-			$products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) );
111
+			$products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text'));
112 112
 		}
113 113
 
114
-		foreach( $products as $product )
114
+		foreach ($products as $product)
115 115
 		{
116
-			$prices = $product->getRefItems( 'price', 'default', 'default' );
116
+			$prices = $product->getRefItems('price', 'default', 'default');
117 117
 
118 118
 			$orderProduct = $orderProductManager->createItem();
119
-			$orderProduct->copyFrom( $product );
120
-			$orderProduct->setStockType( $stocktype );
121
-			$orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) );
119
+			$orderProduct->copyFrom($product);
120
+			$orderProduct->setStockType($stocktype);
121
+			$orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity));
122 122
 
123 123
 			$orderProducts[] = $orderProduct;
124 124
 		}
125 125
 
126
-		$orderBaseProductItem->setProducts( $orderProducts );
126
+		$orderBaseProductItem->setProducts($orderProducts);
127 127
 	}
128 128
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Category.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,26 +36,26 @@
 block discarded – undo
36 36
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
37 37
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
38 38
 	 */
39
-	public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
40
-		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] )
39
+	public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
40
+		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [])
41 41
 	{
42
-		$catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' );
42
+		$catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists');
43 43
 
44
-		$search = $catalogListManager->createSearch( true );
44
+		$search = $catalogListManager->createSearch(true);
45 45
 		$expr = array(
46
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
47
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
46
+			$search->compare('==', 'catalog.lists.domain', 'product'),
47
+			$search->compare('==', 'catalog.lists.refid', $prodid),
48 48
 			$search->getConditions()
49 49
 		);
50
-		$search->setConditions( $search->combine( '&&', $expr ) );
51
-		$search->setSlice( 0, 1 );
50
+		$search->setConditions($search->combine('&&', $expr));
51
+		$search->setSlice(0, 1);
52 52
 
53
-		$result = $catalogListManager->searchItems( $search );
53
+		$result = $catalogListManager->searchItems($search);
54 54
 
55
-		if( reset( $result ) === false )
55
+		if (reset($result) === false)
56 56
 		{
57
-			$msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid );
58
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
57
+			$msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid);
58
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
59 59
 		}
60 60
 
61 61
 		$this->getController()->addProduct(
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Select.php 1 patch
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -36,14 +36,14 @@  discard block
 block discarded – undo
36 36
 	 * @param string $stocktype Unique code of the stock type to deliver the products from
37 37
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
38 38
 	 */
39
-	public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
40
-		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] )
39
+	public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
40
+		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [])
41 41
 	{
42 42
 		$context = $this->getContext();
43
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
44
-		$productItem = $productManager->getItem( $prodid, [], true );
43
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
44
+		$productItem = $productManager->getItem($prodid, [], true);
45 45
 
46
-		if( $productManager->getItem( $prodid, [], true )->getType() !== 'select' )
46
+		if ($productManager->getItem($prodid, [], true)->getType() !== 'select')
47 47
 		{
48 48
 			return $this->getController()->addProduct(
49 49
 				$prodid, $quantity, $stocktype, $variantAttributeIds,
@@ -51,29 +51,29 @@  discard block
 block discarded – undo
51 51
 			);
52 52
 		}
53 53
 
54
-		$productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true );
55
-		$prices = $productItem->getRefItems( 'price', 'default', 'default' );
54
+		$productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true);
55
+		$prices = $productItem->getRefItems('price', 'default', 'default');
56 56
 
57
-		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem();
58
-		$orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype );
57
+		$orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem();
58
+		$orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype);
59 59
 
60
-		$attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds );
60
+		$attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds);
61 61
 
62 62
 		$attributeMap = [
63
-			'custom' => array_keys( $customAttributeValues ),
64
-			'config' => array_keys( $configAttributeIds ),
63
+			'custom' => array_keys($customAttributeValues),
64
+			'config' => array_keys($configAttributeIds),
65 65
 			'hidden' => $hiddenAttributeIds,
66 66
 		];
67
-		$this->checkListRef( array( $prodid, $productItem->getId() ), 'attribute', $attributeMap );
67
+		$this->checkListRef(array($prodid, $productItem->getId()), 'attribute', $attributeMap);
68 68
 
69
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ) );
70
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', array_keys( $configAttributeIds ), [], $configAttributeIds ) );
71
-		$attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) );
69
+		$attr = array_merge($attr, $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues));
70
+		$attr = array_merge($attr, $this->getOrderProductAttributes('config', array_keys($configAttributeIds), [], $configAttributeIds));
71
+		$attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds));
72 72
 
73
-		$orderBaseProductItem->setAttributes( $attr );
74
-		$orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) );
73
+		$orderBaseProductItem->setAttributes($attr);
74
+		$orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity));
75 75
 
76
-		$this->getController()->get()->addProduct( $orderBaseProductItem );
76
+		$this->getController()->get()->addProduct($orderBaseProductItem);
77 77
 		$this->getController()->save();
78 78
 	}
79 79
 
@@ -88,12 +88,12 @@  discard block
 block discarded – undo
88 88
 	 * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes
89 89
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found
90 90
 	 */
91
-	protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
92
-		\Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds )
91
+	protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem,
92
+		\Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds)
93 93
 	{
94 94
 		$attr = [];
95 95
 		$context = $this->getContext();
96
-		$productItems = $this->getProductVariants( $productItem, $variantAttributeIds );
96
+		$productItems = $this->getProductVariants($productItem, $variantAttributeIds);
97 97
 
98 98
 		/** controller/frontend/basket/require-variant
99 99
 		 * A variant of a selection product must be chosen
@@ -114,47 +114,47 @@  discard block
 block discarded – undo
114 114
 		 * @category Developer
115 115
 		 * @category User
116 116
 		 */
117
-		$requireVariant = $context->getConfig()->get( 'controller/frontend/basket/require-variant', true );
117
+		$requireVariant = $context->getConfig()->get('controller/frontend/basket/require-variant', true);
118 118
 
119 119
 
120
-		if( count( $productItems ) > 1 )
120
+		if (count($productItems) > 1)
121 121
 		{
122
-			$msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() );
123
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
122
+			$msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId());
123
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
124 124
 		}
125
-		else if( ( $result = reset( $productItems ) ) !== false ) // count == 1
125
+		else if (($result = reset($productItems)) !== false) // count == 1
126 126
 		{
127 127
 			$productItem = $result;
128
-			$orderBaseProductItem->setProductCode( $productItem->getCode() );
128
+			$orderBaseProductItem->setProductCode($productItem->getCode());
129 129
 
130
-			$subprices = $productItem->getRefItems( 'price', 'default', 'default' );
130
+			$subprices = $productItem->getRefItems('price', 'default', 'default');
131 131
 
132
-			if( !empty( $subprices ) ) {
132
+			if (!empty($subprices)) {
133 133
 				$prices = $subprices;
134 134
 			}
135 135
 
136
-			$submedia = $productItem->getRefItems( 'media', 'default', 'default' );
136
+			$submedia = $productItem->getRefItems('media', 'default', 'default');
137 137
 
138
-			if( ( $mediaItem = reset( $submedia ) ) !== false ) {
139
-				$orderBaseProductItem->setMediaUrl( $mediaItem->getPreview() );
138
+			if (($mediaItem = reset($submedia)) !== false) {
139
+				$orderBaseProductItem->setMediaUrl($mediaItem->getPreview());
140 140
 			}
141 141
 
142
-			$orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' );
143
-			$variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' );
142
+			$orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute');
143
+			$variantAttributes = $productItem->getRefItems('attribute', null, 'variant');
144 144
 
145
-			foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem )
145
+			foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem)
146 146
 			{
147 147
 				$orderAttributeItem = $orderProductAttrManager->createItem();
148
-				$orderAttributeItem->copyFrom( $attrItem );
149
-				$orderAttributeItem->setType( 'variant' );
148
+				$orderAttributeItem->copyFrom($attrItem);
149
+				$orderAttributeItem->setType('variant');
150 150
 
151 151
 				$attr[] = $orderAttributeItem;
152 152
 			}
153 153
 		}
154
-		else if( $requireVariant != false ) // count == 0
154
+		else if ($requireVariant != false) // count == 0
155 155
 		{
156
-			$msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() );
157
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
156
+			$msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId());
157
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
158 158
 		}
159 159
 
160 160
 		return $attr;
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Decorator/Base.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -30,18 +30,18 @@  discard block
 block discarded – undo
30 30
 	 * @param \Aimeos\Controller\Frontend\Iface $controller Controller object
31 31
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects
32 32
 	 */
33
-	public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context )
33
+	public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context)
34 34
 	{
35 35
 		$iface = '\Aimeos\Controller\Frontend\Basket\Iface';
36
-		if( !( $controller instanceof $iface ) )
36
+		if (!($controller instanceof $iface))
37 37
 		{
38
-			$msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface );
39
-			throw new \Aimeos\Controller\Frontend\Exception( $msg );
38
+			$msg = sprintf('Class "%1$s" does not implement interface "%2$s"', get_class($controller), $iface);
39
+			throw new \Aimeos\Controller\Frontend\Exception($msg);
40 40
 		}
41 41
 
42 42
 		$this->controller = $controller;
43 43
 
44
-		parent::__construct( $context );
44
+		parent::__construct($context);
45 45
 	}
46 46
 
47 47
 
@@ -53,9 +53,9 @@  discard block
 block discarded – undo
53 53
 	 * @return mixed Returns the value of the called method
54 54
 	 * @throws \Aimeos\Controller\Frontend\Exception If method call failed
55 55
 	 */
56
-	public function __call( $name, array $param )
56
+	public function __call($name, array $param)
57 57
 	{
58
-		return @call_user_func_array( array( $this->controller, $name ), $param );
58
+		return @call_user_func_array(array($this->controller, $name), $param);
59 59
 	}
60 60
 
61 61
 
@@ -97,9 +97,9 @@  discard block
 block discarded – undo
97 97
 	 * @param string $type Basket type
98 98
 	 * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object
99 99
 	 */
100
-	public function setType( $type )
100
+	public function setType($type)
101 101
 	{
102
-		$this->controller->setType( $type );
102
+		$this->controller->setType($type);
103 103
 		return $this;
104 104
 	}
105 105
 
@@ -123,9 +123,9 @@  discard block
 block discarded – undo
123 123
 	 * @param boolean $default True to add default criteria (user logged in), false if not
124 124
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts
125 125
 	 */
126
-	public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true )
126
+	public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true)
127 127
 	{
128
-		return $this->controller->load( $id, $parts, $default );
128
+		return $this->controller->load($id, $parts, $default);
129 129
 	}
130 130
 
131 131
 
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
151 151
 	 * @return void
152 152
 	 */
153
-	public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
154
-		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] )
153
+	public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
154
+		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [])
155 155
 	{
156 156
 		$this->controller->addProduct(
157 157
 			$prodid, $quantity, $stocktype, $variantAttributeIds,
@@ -166,9 +166,9 @@  discard block
 block discarded – undo
166 166
 	 * @param integer $position Position number (key) of the order product item
167 167
 	 * @return void
168 168
 	 */
169
-	public function deleteProduct( $position )
169
+	public function deleteProduct($position)
170 170
 	{
171
-		$this->controller->deleteProduct( $position );
171
+		$this->controller->deleteProduct($position);
172 172
 	}
173 173
 
174 174
 
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	 * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED
181 181
 	 * @return void
182 182
 	 */
183
-	public function editProduct( $position, $quantity, array $configAttributeCodes = [] )
183
+	public function editProduct($position, $quantity, array $configAttributeCodes = [])
184 184
 	{
185
-		$this->controller->editProduct( $position, $quantity, $configAttributeCodes );
185
+		$this->controller->editProduct($position, $quantity, $configAttributeCodes);
186 186
 	}
187 187
 
188 188
 
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
194 194
 	 * @return void
195 195
 	 */
196
-	public function addCoupon( $code )
196
+	public function addCoupon($code)
197 197
 	{
198
-		$this->controller->addCoupon( $code );
198
+		$this->controller->addCoupon($code);
199 199
 	}
200 200
 
201 201
 
@@ -206,9 +206,9 @@  discard block
 block discarded – undo
206 206
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
207 207
 	 * @return void
208 208
 	 */
209
-	public function deleteCoupon( $code )
209
+	public function deleteCoupon($code)
210 210
 	{
211
-		$this->controller->deleteCoupon( $code );
211
+		$this->controller->deleteCoupon($code);
212 212
 	}
213 213
 
214 214
 
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	 * 	if one of the keys is invalid when using an array with key/value pairs
222 222
 	 * @return void
223 223
 	 */
224
-	public function setAddress( $type, $value )
224
+	public function setAddress($type, $value)
225 225
 	{
226
-		$this->controller->setAddress( $type, $value );
226
+		$this->controller->setAddress($type, $value);
227 227
 	}
228 228
 
229 229
 
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
238 238
 	 * @return void
239 239
 	 */
240
-	public function addService( $type, $id, array $attributes = [] )
240
+	public function addService($type, $id, array $attributes = [])
241 241
 	{
242
-		$this->controller->addService( $type, $id, $attributes );
242
+		$this->controller->addService($type, $id, $attributes);
243 243
 	}
244 244
 
245 245
 
@@ -248,9 +248,9 @@  discard block
 block discarded – undo
248 248
 	 *
249 249
 	 * @param string $type Service type code like 'payment' or 'delivery'
250 250
 	 */
251
-	public function deleteService( $type )
251
+	public function deleteService($type)
252 252
 	{
253
-		$this->controller->deleteService( $type );
253
+		$this->controller->deleteService($type);
254 254
 	}
255 255
 
256 256
 
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Iface.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * @param string $type Basket type
51 51
 	 * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object
52 52
 	 */
53
-	public function setType( $type );
53
+	public function setType($type);
54 54
 
55 55
 
56 56
 	/**
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @param boolean $default True to add default criteria (user logged in), false if not
70 70
 	 * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts
71 71
 	 */
72
-	public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true );
72
+	public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true);
73 73
 
74 74
 
75 75
 	/**
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available
89 89
 	 * @return void
90 90
 	 */
91
-	public function addProduct( $prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
92
-		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [] );
91
+	public function addProduct($prodid, $quantity = 1, $stocktype = 'default', array $variantAttributeIds = [],
92
+		array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = []);
93 93
 
94 94
 
95 95
 	/**
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
 	 * @param integer $position Position number (key) of the order product item
99 99
 	 * @return void
100 100
 	 */
101
-	public function deleteProduct( $position );
101
+	public function deleteProduct($position);
102 102
 
103 103
 
104 104
 	/**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
 	 * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED
110 110
 	 * @return void
111 111
 	 */
112
-	public function editProduct( $position, $quantity, array $configAttributeCodes = [] );
112
+	public function editProduct($position, $quantity, array $configAttributeCodes = []);
113 113
 
114 114
 
115 115
 	/**
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed
120 120
 	 * @return void
121 121
 	 */
122
-	public function addCoupon( $code );
122
+	public function addCoupon($code);
123 123
 
124 124
 
125 125
 	/**
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid
130 130
 	 * @return void
131 131
 	 */
132
-	public function deleteCoupon( $code );
132
+	public function deleteCoupon($code);
133 133
 
134 134
 
135 135
 	/**
@@ -141,7 +141,7 @@  discard block
 block discarded – undo
141 141
 	 * 	if one of the keys is invalid when using an array with key/value pairs
142 142
 	 * @return void
143 143
 	 */
144
-	public function setAddress( $type, $value );
144
+	public function setAddress($type, $value);
145 145
 
146 146
 
147 147
 	/**
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 	 * 	entered by the customer when choosing one of the delivery or payment options
154 154
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached
155 155
 	 */
156
-	public function addService( $type, $id, array $attributes = [] );
156
+	public function addService($type, $id, array $attributes = []);
157 157
 
158 158
 
159 159
 	/**
@@ -161,5 +161,5 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @param string $type Service type code like 'payment' or 'delivery'
163 163
 	 */
164
-	public function deleteService( $type );
164
+	public function deleteService($type);
165 165
 }
Please login to merge, or discard this patch.
controller/frontend/src/Controller/Frontend/Basket/Base.php 1 patch
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -31,52 +31,52 @@  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( $context, 'product' );
41
-			$prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' );
40
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'product');
41
+			$prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default');
42 42
 		}
43 43
 
44 44
 
45
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
46
-		$price = $priceManager->getLowestPrice( $prices, $quantity );
45
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
46
+		$price = $priceManager->getLowestPrice($prices, $quantity);
47 47
 
48 48
 		// customers can pay what they would like to pay
49
-		if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null )
49
+		if (($attr = $product->getAttributeItem('price', 'custom')) !== null)
50 50
 		{
51 51
 			$amount = $attr->getValue();
52 52
 
53
-			if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 )
53
+			if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01)
54 54
 			{
55
-				$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid price value "%1$s"' );
56
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $amount ) );
55
+				$msg = $context->getI18n()->dt('controller/frontend', 'Invalid price value "%1$s"');
56
+				throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $amount));
57 57
 			}
58 58
 
59
-			$price->setValue( $amount );
59
+			$price->setValue($amount);
60 60
 		}
61 61
 
62 62
 		$orderAttributes = $product->getAttributes();
63
-		$attrItems = $this->getAttributeItems( $orderAttributes );
63
+		$attrItems = $this->getAttributeItems($orderAttributes);
64 64
 
65 65
 		// add prices of (optional) attributes
66
-		foreach( $orderAttributes as $orderAttrItem )
66
+		foreach ($orderAttributes as $orderAttrItem)
67 67
 		{
68 68
 			$attrId = $orderAttrItem->getAttributeId();
69 69
 
70
-			if( isset( $attrItems[$attrId] )
71
-				&& ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== []
70
+			if (isset($attrItems[$attrId])
71
+				&& ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== []
72 72
 			) {
73
-				$attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() );
74
-				$price->addItem( $attrPrice, $orderAttrItem->getQuantity() );
73
+				$attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity());
74
+				$price->addItem($attrPrice, $orderAttrItem->getQuantity());
75 75
 			}
76 76
 		}
77 77
 
78 78
 		// remove product rebate of original price in favor to rebates granted for the order
79
-		$price->setRebate( '0.00' );
79
+		$price->setRebate('0.00');
80 80
 
81 81
 		return $price;
82 82
 	}
@@ -90,43 +90,43 @@  discard block
 block discarded – undo
90 90
 	 * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values
91 91
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
92 92
 	 */
93
-	protected function checkListRef( $prodId, $domain, array $refMap )
93
+	protected function checkListRef($prodId, $domain, array $refMap)
94 94
 	{
95
-		if( empty( $refMap ) ) {
95
+		if (empty($refMap)) {
96 96
 			return;
97 97
 		}
98 98
 
99 99
 		$context = $this->getContext();
100
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
101
-		$search = $productManager->createSearch( true );
100
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
101
+		$search = $productManager->createSearch(true);
102 102
 
103 103
 		$expr = array(
104
-			$search->compare( '==', 'product.id', $prodId ),
104
+			$search->compare('==', 'product.id', $prodId),
105 105
 			$search->getConditions(),
106 106
 		);
107 107
 
108
-		foreach( $refMap as $listType => $refIds )
108
+		foreach ($refMap as $listType => $refIds)
109 109
 		{
110
-			if( empty( $refIds ) ) {
110
+			if (empty($refIds)) {
111 111
 				continue;
112 112
 			}
113 113
 
114
-			foreach( $refIds as $key => $refId ) {
114
+			foreach ($refIds as $key => $refId) {
115 115
 				$refIds[$key] = (string) $refId;
116 116
 			}
117 117
 
118
-			$param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds );
119
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
118
+			$param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds);
119
+			$cmpfunc = $search->createFunction('product.contains', $param);
120 120
 
121
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
121
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
122 122
 		}
123 123
 
124
-		$search->setConditions( $search->combine( '&&', $expr ) );
124
+		$search->setConditions($search->combine('&&', $expr));
125 125
 
126
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
126
+		if (count($productManager->searchItems($search, [])) === 0)
127 127
 		{
128
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' );
129
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) );
128
+			$msg = $context->getI18n()->dt('controller/frontend', 'Invalid "%1$s" references for product with ID %2$s');
129
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, json_encode($prodId)));
130 130
 		}
131 131
 	}
132 132
 
@@ -141,35 +141,35 @@  discard block
 block discarded – undo
141 141
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
142 142
 	 * @deprecated Use checkListRef() instead
143 143
 	 */
144
-	protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds )
144
+	protected function checkReferences($prodId, $domain, $listTypeId, array $refIds)
145 145
 	{
146 146
 		$context = $this->getContext();
147
-		$productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' );
148
-		$search = $productManager->createSearch( true );
147
+		$productManager = \Aimeos\MShop\Factory::createManager($context, 'product');
148
+		$search = $productManager->createSearch(true);
149 149
 
150 150
 		$expr = array(
151
-			$search->compare( '==', 'product.id', $prodId ),
151
+			$search->compare('==', 'product.id', $prodId),
152 152
 			$search->getConditions(),
153 153
 		);
154 154
 
155
-		if( count( $refIds ) > 0 )
155
+		if (count($refIds) > 0)
156 156
 		{
157
-			foreach( $refIds as $key => $refId ) {
157
+			foreach ($refIds as $key => $refId) {
158 158
 				$refIds[$key] = (string) $refId;
159 159
 			}
160 160
 
161
-			$param = array( $domain, $listTypeId, $refIds );
162
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
161
+			$param = array($domain, $listTypeId, $refIds);
162
+			$cmpfunc = $search->createFunction('product.contains', $param);
163 163
 
164
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
164
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
165 165
 		}
166 166
 
167
-		$search->setConditions( $search->combine( '&&', $expr ) );
167
+		$search->setConditions($search->combine('&&', $expr));
168 168
 
169
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
169
+		if (count($productManager->searchItems($search, [])) === 0)
170 170
 		{
171
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Invalid "%1$s" references for product with ID %2$s' );
172
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, json_encode( $prodId ) ) );
171
+			$msg = $context->getI18n()->dt('controller/frontend', 'Invalid "%1$s" references for product with ID %2$s');
172
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, json_encode($prodId)));
173 173
 		}
174 174
 	}
175 175
 
@@ -179,41 +179,41 @@  discard block
 block discarded – undo
179 179
 	 *
180 180
 	 * @param string $type Basket type
181 181
 	 */
182
-	protected function checkLocale( $type )
182
+	protected function checkLocale($type)
183 183
 	{
184 184
 		$errors = [];
185 185
 		$context = $this->getContext();
186 186
 		$session = $context->getSession();
187 187
 		$locale = $this->get()->getLocale();
188 188
 
189
-		$localeStr = $session->get( 'aimeos/basket/locale' );
189
+		$localeStr = $session->get('aimeos/basket/locale');
190 190
 		$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
191 191
 
192
-		if( $localeStr !== null && $localeStr !== $localeKey )
192
+		if ($localeStr !== null && $localeStr !== $localeKey)
193 193
 		{
194
-			$locParts = explode( '|', $localeStr );
195
-			$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
196
-			$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
197
-			$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
194
+			$locParts = explode('|', $localeStr);
195
+			$locSite = (isset($locParts[0]) ? $locParts[0] : '');
196
+			$locLanguage = (isset($locParts[1]) ? $locParts[1] : '');
197
+			$locCurrency = (isset($locParts[2]) ? $locParts[2] : '');
198 198
 
199
-			$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
200
-			$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
199
+			$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
200
+			$locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false);
201 201
 
202 202
 			$context = clone $context;
203
-			$context->setLocale( $locale );
203
+			$context->setLocale($locale);
204 204
 
205
-			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' );
206
-			$basket = $manager->getSession( $type );
205
+			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base');
206
+			$basket = $manager->getSession($type);
207 207
 
208
-			$this->copyAddresses( $basket, $errors, $localeKey );
209
-			$this->copyServices( $basket, $errors );
210
-			$this->copyProducts( $basket, $errors, $localeKey );
211
-			$this->copyCoupons( $basket, $errors, $localeKey );
208
+			$this->copyAddresses($basket, $errors, $localeKey);
209
+			$this->copyServices($basket, $errors);
210
+			$this->copyProducts($basket, $errors, $localeKey);
211
+			$this->copyCoupons($basket, $errors, $localeKey);
212 212
 
213
-			$manager->setSession( $basket, $type );
213
+			$manager->setSession($basket, $type);
214 214
 		}
215 215
 
216
-		$session->set( 'aimeos/basket/locale', $localeKey );
216
+		$session->set('aimeos/basket/locale', $localeKey);
217 217
 	}
218 218
 
219 219
 
@@ -225,22 +225,22 @@  discard block
 block discarded – undo
225 225
 	 * @param string $localeKey Unique identifier of the site, language and currency
226 226
 	 * @return array Associative list of errors occured
227 227
 	 */
228
-	protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
228
+	protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
229 229
 	{
230
-		foreach( $basket->getAddresses() as $type => $item )
230
+		foreach ($basket->getAddresses() as $type => $item)
231 231
 		{
232 232
 			try
233 233
 			{
234
-				$this->setAddress( $type, $item->toArray() );
235
-				$basket->deleteAddress( $type );
234
+				$this->setAddress($type, $item->toArray());
235
+				$basket->deleteAddress($type);
236 236
 			}
237
-			catch( \Exception $e )
237
+			catch (\Exception $e)
238 238
 			{
239 239
 				$logger = $this->getContext()->getLogger();
240 240
 				$errors['address'][$type] = $e->getMessage();
241 241
 
242 242
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
243
-				$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
243
+				$logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
244 244
 			}
245 245
 		}
246 246
 
@@ -256,22 +256,22 @@  discard block
 block discarded – undo
256 256
 	 * @param string $localeKey Unique identifier of the site, language and currency
257 257
 	 * @return array Associative list of errors occured
258 258
 	 */
259
-	protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
259
+	protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
260 260
 	{
261
-		foreach( $basket->getCoupons() as $code => $list )
261
+		foreach ($basket->getCoupons() as $code => $list)
262 262
 		{
263 263
 			try
264 264
 			{
265
-				$this->addCoupon( $code );
266
-				$basket->deleteCoupon( $code, true );
265
+				$this->addCoupon($code);
266
+				$basket->deleteCoupon($code, true);
267 267
 			}
268
-			catch( \Exception $e )
268
+			catch (\Exception $e)
269 269
 			{
270 270
 				$logger = $this->getContext()->getLogger();
271 271
 				$errors['coupon'][$code] = $e->getMessage();
272 272
 
273 273
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
274
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
274
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
275 275
 			}
276 276
 		}
277 277
 
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 	 * @param string $localeKey Unique identifier of the site, language and currency
288 288
 	 * @return array Associative list of errors occured
289 289
 	 */
290
-	protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
290
+	protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
291 291
 	{
292
-		foreach( $basket->getProducts() as $pos => $product )
292
+		foreach ($basket->getProducts() as $pos => $product)
293 293
 		{
294
-			if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) {
294
+			if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) {
295 295
 				continue;
296 296
 			}
297 297
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 			{
300 300
 				$attrIds = [];
301 301
 
302
-				foreach( $product->getAttributes() as $attrItem ) {
302
+				foreach ($product->getAttributes() as $attrItem) {
303 303
 					$attrIds[$attrItem->getType()][] = $attrItem->getAttributeId();
304 304
 				}
305 305
 
@@ -307,22 +307,22 @@  discard block
 block discarded – undo
307 307
 					$product->getProductId(),
308 308
 					$product->getQuantity(),
309 309
 					$product->getStockType(),
310
-					$this->getValue( $attrIds, 'variant', [] ),
311
-					$this->getValue( $attrIds, 'config', [] ),
312
-					$this->getValue( $attrIds, 'hidden', [] ),
313
-					$this->getValue( $attrIds, 'custom', [] )
310
+					$this->getValue($attrIds, 'variant', []),
311
+					$this->getValue($attrIds, 'config', []),
312
+					$this->getValue($attrIds, 'hidden', []),
313
+					$this->getValue($attrIds, 'custom', [])
314 314
 				);
315 315
 
316
-				$basket->deleteProduct( $pos );
316
+				$basket->deleteProduct($pos);
317 317
 			}
318
-			catch( \Exception $e )
318
+			catch (\Exception $e)
319 319
 			{
320 320
 				$code = $product->getProductCode();
321 321
 				$logger = $this->getContext()->getLogger();
322 322
 				$errors['product'][$pos] = $e->getMessage();
323 323
 
324 324
 				$str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s';
325
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
325
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
326 326
 			}
327 327
 		}
328 328
 
@@ -337,24 +337,24 @@  discard block
 block discarded – undo
337 337
 	 * @param array $errors Associative list of previous errors
338 338
 	 * @return array Associative list of errors occured
339 339
 	 */
340
-	protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
340
+	protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors)
341 341
 	{
342
-		foreach( $basket->getServices() as $type => $list )
342
+		foreach ($basket->getServices() as $type => $list)
343 343
 		{
344
-			foreach( $list as $item )
344
+			foreach ($list as $item)
345 345
 			{
346 346
 				try
347 347
 				{
348 348
 					$attributes = [];
349 349
 
350
-					foreach( $item->getAttributes() as $attrItem ) {
350
+					foreach ($item->getAttributes() as $attrItem) {
351 351
 						$attributes[$attrItem->getCode()] = $attrItem->getValue();
352 352
 					}
353 353
 
354
-					$this->addService( $type, $item->getServiceId(), $attributes );
355
-					$basket->deleteService( $type );
354
+					$this->addService($type, $item->getServiceId(), $attributes);
355
+					$basket->deleteService($type);
356 356
 				}
357
-				catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
357
+				catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically
358 358
 			}
359 359
 		}
360 360
 
@@ -374,35 +374,35 @@  discard block
 block discarded – undo
374 374
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
375 375
 	 * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead
376 376
 	 */
377
-	protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
378
-			array $attributeIds, $type, array $attributeValues = [] )
377
+	protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
378
+			array $attributeIds, $type, array $attributeValues = [])
379 379
 	{
380
-		if( empty( $attributeIds ) ) {
380
+		if (empty($attributeIds)) {
381 381
 			return [];
382 382
 		}
383 383
 
384 384
 		$list = [];
385 385
 		$context = $this->getContext();
386
-		$attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId();
387
-		$this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds );
386
+		$attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId();
387
+		$this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds);
388 388
 
389
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
390
-		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' );
389
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
390
+		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute');
391 391
 
392
-		foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem )
392
+		foreach ($this->getAttributes($attributeIds) as $id => $attrItem)
393 393
 		{
394
-			$prices = $attrItem->getRefItems( 'price', 'default', 'default' );
394
+			$prices = $attrItem->getRefItems('price', 'default', 'default');
395 395
 
396
-			if( !empty( $prices ) ) {
397
-				$price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) );
396
+			if (!empty($prices)) {
397
+				$price->addItem($priceManager->getLowestPrice($prices, $quantity));
398 398
 			}
399 399
 
400 400
 			$item = $orderProductAttributeManager->createItem();
401
-			$item->copyFrom( $attrItem );
402
-			$item->setType( $type );
401
+			$item->copyFrom($attrItem);
402
+			$item->setType($type);
403 403
 
404
-			if( isset( $attributeValues[$id] ) ) {
405
-				$item->setValue( $attributeValues[$id] );
404
+			if (isset($attributeValues[$id])) {
405
+				$item->setValue($attributeValues[$id]);
406 406
 			}
407 407
 
408 408
 			$list[] = $item;
@@ -420,32 +420,32 @@  discard block
 block discarded – undo
420 420
 	 * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
421 421
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
422 422
 	 */
423
-	protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) )
423
+	protected function getAttributes(array $attributeIds, array $domains = array('price', 'text'))
424 424
 	{
425
-		if( empty( $attributeIds ) ) {
425
+		if (empty($attributeIds)) {
426 426
 			return [];
427 427
 		}
428 428
 
429
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
429
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
430 430
 
431
-		$search = $attributeManager->createSearch( true );
431
+		$search = $attributeManager->createSearch(true);
432 432
 		$expr = array(
433
-			$search->compare( '==', 'attribute.id', $attributeIds ),
433
+			$search->compare('==', 'attribute.id', $attributeIds),
434 434
 			$search->getConditions(),
435 435
 		);
436
-		$search->setConditions( $search->combine( '&&', $expr ) );
437
-		$search->setSlice( 0, 0x7fffffff );
436
+		$search->setConditions($search->combine('&&', $expr));
437
+		$search->setSlice(0, 0x7fffffff);
438 438
 
439
-		$attrItems = $attributeManager->searchItems( $search, $domains );
439
+		$attrItems = $attributeManager->searchItems($search, $domains);
440 440
 
441
-		if( count( $attrItems ) !== count( $attributeIds ) )
441
+		if (count($attrItems) !== count($attributeIds))
442 442
 		{
443 443
 			$i18n = $this->getContext()->getI18n();
444
-			$expected = implode( ',', $attributeIds );
445
-			$actual = implode( ',', array_keys( $attrItems ) );
446
-			$msg = $i18n->dt( 'controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"' );
444
+			$expected = implode(',', $attributeIds);
445
+			$actual = implode(',', array_keys($attrItems));
446
+			$msg = $i18n->dt('controller/frontend', 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"');
447 447
 
448
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $actual, $expected ) );
448
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $actual, $expected));
449 449
 		}
450 450
 
451 451
 		return $attrItems;
@@ -458,31 +458,31 @@  discard block
 block discarded – undo
458 458
 	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
459 459
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
460 460
 	 */
461
-	protected function getAttributeItems( array $orderAttributes )
461
+	protected function getAttributeItems(array $orderAttributes)
462 462
 	{
463
-		if( empty( $orderAttributes ) ) {
463
+		if (empty($orderAttributes)) {
464 464
 			return [];
465 465
 		}
466 466
 
467
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
468
-		$search = $attributeManager->createSearch( true );
467
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
468
+		$search = $attributeManager->createSearch(true);
469 469
 		$expr = [];
470 470
 
471
-		foreach( $orderAttributes as $item )
471
+		foreach ($orderAttributes as $item)
472 472
 		{
473 473
 			$tmp = array(
474
-				$search->compare( '==', 'attribute.domain', 'product' ),
475
-				$search->compare( '==', 'attribute.code', $item->getValue() ),
476
-				$search->compare( '==', 'attribute.type.domain', 'product' ),
477
-				$search->compare( '==', 'attribute.type.code', $item->getCode() ),
478
-				$search->compare( '>', 'attribute.type.status', 0 ),
474
+				$search->compare('==', 'attribute.domain', 'product'),
475
+				$search->compare('==', 'attribute.code', $item->getValue()),
476
+				$search->compare('==', 'attribute.type.domain', 'product'),
477
+				$search->compare('==', 'attribute.type.code', $item->getCode()),
478
+				$search->compare('>', 'attribute.type.status', 0),
479 479
 				$search->getConditions(),
480 480
 			);
481
-			$expr[] = $search->combine( '&&', $tmp );
481
+			$expr[] = $search->combine('&&', $tmp);
482 482
 		}
483 483
 
484
-		$search->setConditions( $search->combine( '||', $expr ) );
485
-		return $attributeManager->searchItems( $search, array( 'price' ) );
484
+		$search->setConditions($search->combine('||', $expr));
485
+		return $attributeManager->searchItems($search, array('price'));
486 486
 	}
487 487
 
488 488
 
@@ -497,24 +497,24 @@  discard block
 block discarded – undo
497 497
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
498 498
 	 * @deprecated Use getItem() or findItem() instead
499 499
 	 */
500
-	protected function getDomainItem( $domain, $key, $value, array $ref )
500
+	protected function getDomainItem($domain, $key, $value, array $ref)
501 501
 	{
502 502
 		$context = $this->getContext();
503
-		$manager = \Aimeos\MShop\Factory::createManager( $context, $domain );
503
+		$manager = \Aimeos\MShop\Factory::createManager($context, $domain);
504 504
 
505
-		$search = $manager->createSearch( true );
505
+		$search = $manager->createSearch(true);
506 506
 		$expr = array(
507
-			$search->compare( '==', $key, $value ),
507
+			$search->compare('==', $key, $value),
508 508
 			$search->getConditions(),
509 509
 		);
510
-		$search->setConditions( $search->combine( '&&', $expr ) );
510
+		$search->setConditions($search->combine('&&', $expr));
511 511
 
512
-		$result = $manager->searchItems( $search, $ref );
512
+		$result = $manager->searchItems($search, $ref);
513 513
 
514
-		if( ( $item = reset( $result ) ) === false )
514
+		if (($item = reset($result)) === false)
515 515
 		{
516
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'No item for "%1$s" (%2$s) found' );
517
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $value, $key ) );
516
+			$msg = $context->getI18n()->dt('controller/frontend', 'No item for "%1$s" (%2$s) found');
517
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $value, $key));
518 518
 		}
519 519
 
520 520
 		return $item;
@@ -530,24 +530,24 @@  discard block
 block discarded – undo
530 530
 	 * @param array $quantities Associative list of attribute IDs as keys and their quantities as values
531 531
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
532 532
 	 */
533
-	protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] )
533
+	protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = [])
534 534
 	{
535
-		if( empty( $ids ) ) {
535
+		if (empty($ids)) {
536 536
 			return [];
537 537
 		}
538 538
 
539 539
 		$list = [];
540
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' );
540
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute');
541 541
 
542
-		foreach( $this->getAttributes( $ids ) as $id => $attrItem )
542
+		foreach ($this->getAttributes($ids) as $id => $attrItem)
543 543
 		{
544 544
 			$item = $manager->createItem();
545
-			$item->copyFrom( $attrItem );
546
-			$item->setType( $type );
547
-			$item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 );
545
+			$item->copyFrom($attrItem);
546
+			$item->setType($type);
547
+			$item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1);
548 548
 
549
-			if( isset( $values[$id] ) ) {
550
-				$item->setValue( $values[$id] );
549
+			if (isset($values[$id])) {
550
+				$item->setValue($values[$id]);
551 551
 			}
552 552
 
553 553
 			$list[] = $item;
@@ -564,23 +564,23 @@  discard block
 block discarded – undo
564 564
 	 * @param string $code Code of the list type
565 565
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface List type item
566 566
 	 */
567
-	protected function getProductListTypeItem( $domain, $code )
567
+	protected function getProductListTypeItem($domain, $code)
568 568
 	{
569 569
 		$context = $this->getContext();
570 570
 
571
-		if( empty( $this->listTypeItems ) )
571
+		if (empty($this->listTypeItems))
572 572
 		{
573
-			$manager = \Aimeos\MShop\Factory::createManager( $context, 'product/lists/type' );
573
+			$manager = \Aimeos\MShop\Factory::createManager($context, 'product/lists/type');
574 574
 
575
-			foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) {
576
-				$this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item;
575
+			foreach ($manager->searchItems($manager->createSearch(true)) as $item) {
576
+				$this->listTypeItems[$item->getDomain()][$item->getCode()] = $item;
577 577
 			}
578 578
 		}
579 579
 
580
-		if( !isset( $this->listTypeItems[$domain][$code] ) )
580
+		if (!isset($this->listTypeItems[$domain][$code]))
581 581
 		{
582
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found' );
583
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $domain, $code ) );
582
+			$msg = $context->getI18n()->dt('controller/frontend', 'List type for domain "%1$s" and code "%2$s" not found');
583
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $domain, $code));
584 584
 		}
585 585
 
586 586
 		return $this->listTypeItems[$domain][$code];
@@ -595,43 +595,43 @@  discard block
 block discarded – undo
595 595
 	 * @param array $domains Names of the domain items that should be fetched too
596 596
 	 * @return array List of products matching the given attributes
597 597
 	 */
598
-	protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
599
-			array $domains = array( 'attribute', 'media', 'price', 'text' ) )
598
+	protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
599
+			array $domains = array('attribute', 'media', 'price', 'text'))
600 600
 	{
601 601
 		$subProductIds = [];
602
-		foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) {
602
+		foreach ($productItem->getRefItems('product', 'default', 'default') as $item) {
603 603
 			$subProductIds[] = $item->getId();
604 604
 		}
605 605
 
606
-		if( count( $subProductIds ) === 0 ) {
606
+		if (count($subProductIds) === 0) {
607 607
 			return [];
608 608
 		}
609 609
 
610
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
611
-		$search = $productManager->createSearch( true );
610
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
611
+		$search = $productManager->createSearch(true);
612 612
 
613 613
 		$expr = array(
614
-			$search->compare( '==', 'product.id', $subProductIds ),
614
+			$search->compare('==', 'product.id', $subProductIds),
615 615
 			$search->getConditions(),
616 616
 		);
617 617
 
618
-		if( count( $variantAttributeIds ) > 0 )
618
+		if (count($variantAttributeIds) > 0)
619 619
 		{
620
-			foreach( $variantAttributeIds as $key => $id ) {
620
+			foreach ($variantAttributeIds as $key => $id) {
621 621
 				$variantAttributeIds[$key] = (string) $id;
622 622
 			}
623 623
 
624
-			$listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' );
624
+			$listTypeItem = $this->getProductListTypeItem('attribute', 'variant');
625 625
 
626
-			$param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds );
627
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
626
+			$param = array('attribute', $listTypeItem->getId(), $variantAttributeIds);
627
+			$cmpfunc = $search->createFunction('product.contains', $param);
628 628
 
629
-			$expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) );
629
+			$expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds));
630 630
 		}
631 631
 
632
-		$search->setConditions( $search->combine( '&&', $expr ) );
632
+		$search->setConditions($search->combine('&&', $expr));
633 633
 
634
-		return $productManager->searchItems( $search, $domains );
634
+		return $productManager->searchItems($search, $domains);
635 635
 	}
636 636
 
637 637
 
@@ -643,9 +643,9 @@  discard block
 block discarded – undo
643 643
 	 * @param mixed $default Default value if no value is available for the given name
644 644
 	 * @return mixed Value from the array or default value
645 645
 	 */
646
-	protected function getValue( array $values, $name, $default = null )
646
+	protected function getValue(array $values, $name, $default = null)
647 647
 	{
648
-		if( isset( $values[$name] ) ) {
648
+		if (isset($values[$name])) {
649 649
 			return $values[$name];
650 650
 		}
651 651
 
Please login to merge, or discard this patch.