Completed
Push — master ( d21ec6...2fc608 )
by Aimeos
01:56
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   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -31,50 +31,50 @@  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 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 ) {
54
-				throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid price value "%1$s"', $amount ) );
53
+			if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) {
54
+				throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid price value "%1$s"', $amount));
55 55
 			}
56 56
 
57
-			$price->setValue( $amount );
57
+			$price->setValue($amount);
58 58
 		}
59 59
 
60 60
 		$orderAttributes = $product->getAttributes();
61
-		$attrItems = $this->getAttributeItems( $orderAttributes );
61
+		$attrItems = $this->getAttributeItems($orderAttributes);
62 62
 
63 63
 		// add prices of (optional) attributes
64
-		foreach( $orderAttributes as $orderAttrItem )
64
+		foreach ($orderAttributes as $orderAttrItem)
65 65
 		{
66 66
 			$attrId = $orderAttrItem->getAttributeId();
67 67
 
68
-			if( isset( $attrItems[$attrId] )
69
-				&& ( $prices = $attrItems[$attrId]->getRefItems( 'price', 'default' ) ) !== []
68
+			if (isset($attrItems[$attrId])
69
+				&& ($prices = $attrItems[$attrId]->getRefItems('price', 'default')) !== []
70 70
 			) {
71
-				$attrPrice = $priceManager->getLowestPrice( $prices, $orderAttrItem->getQuantity() );
72
-				$price->addItem( $attrPrice, $orderAttrItem->getQuantity() );
71
+				$attrPrice = $priceManager->getLowestPrice($prices, $orderAttrItem->getQuantity());
72
+				$price->addItem($attrPrice, $orderAttrItem->getQuantity());
73 73
 			}
74 74
 		}
75 75
 
76 76
 		// remove product rebate of original price in favor to rebates granted for the order
77
-		$price->setRebate( '0.00' );
77
+		$price->setRebate('0.00');
78 78
 
79 79
 		return $price;
80 80
 	}
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 	 * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values
89 89
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
90 90
 	 */
91
-	protected function checkListRef( $prodId, $domain, array $refMap )
91
+	protected function checkListRef($prodId, $domain, array $refMap)
92 92
 	{
93
-		if( empty( $refMap ) ) {
93
+		if (empty($refMap)) {
94 94
 			return;
95 95
 		}
96 96
 
97
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
98
-		$search = $productManager->createSearch( true );
97
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
98
+		$search = $productManager->createSearch(true);
99 99
 
100 100
 		$expr = array(
101
-			$search->compare( '==', 'product.id', $prodId ),
101
+			$search->compare('==', 'product.id', $prodId),
102 102
 			$search->getConditions(),
103 103
 		);
104 104
 
105
-		foreach( $refMap as $listType => $refIds )
105
+		foreach ($refMap as $listType => $refIds)
106 106
 		{
107
-			if( empty( $refIds ) ) {
107
+			if (empty($refIds)) {
108 108
 				continue;
109 109
 			}
110 110
 
111
-			foreach( $refIds as $key => $refId ) {
111
+			foreach ($refIds as $key => $refId) {
112 112
 				$refIds[$key] = (string) $refId;
113 113
 			}
114 114
 
115
-			$param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds );
116
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
115
+			$param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds);
116
+			$cmpfunc = $search->createFunction('product.contains', $param);
117 117
 
118
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
118
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
119 119
 		}
120 120
 
121
-		$search->setConditions( $search->combine( '&&', $expr ) );
121
+		$search->setConditions($search->combine('&&', $expr));
122 122
 
123
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
123
+		if (count($productManager->searchItems($search, [])) === 0)
124 124
 		{
125
-			$msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) );
126
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
125
+			$msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId));
126
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
127 127
 		}
128 128
 	}
129 129
 
@@ -138,34 +138,34 @@  discard block
 block discarded – undo
138 138
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated
139 139
 	 * @deprecated Use checkListRef() instead
140 140
 	 */
141
-	protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds )
141
+	protected function checkReferences($prodId, $domain, $listTypeId, array $refIds)
142 142
 	{
143
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
144
-		$search = $productManager->createSearch( true );
143
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
144
+		$search = $productManager->createSearch(true);
145 145
 
146 146
 		$expr = array(
147
-			$search->compare( '==', 'product.id', $prodId ),
147
+			$search->compare('==', 'product.id', $prodId),
148 148
 			$search->getConditions(),
149 149
 		);
150 150
 
151
-		if( count( $refIds ) > 0 )
151
+		if (count($refIds) > 0)
152 152
 		{
153
-			foreach( $refIds as $key => $refId ) {
153
+			foreach ($refIds as $key => $refId) {
154 154
 				$refIds[$key] = (string) $refId;
155 155
 			}
156 156
 
157
-			$param = array( $domain, $listTypeId, $refIds );
158
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
157
+			$param = array($domain, $listTypeId, $refIds);
158
+			$cmpfunc = $search->createFunction('product.contains', $param);
159 159
 
160
-			$expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) );
160
+			$expr[] = $search->compare('==', $cmpfunc, count($refIds));
161 161
 		}
162 162
 
163
-		$search->setConditions( $search->combine( '&&', $expr ) );
163
+		$search->setConditions($search->combine('&&', $expr));
164 164
 
165
-		if( count( $productManager->searchItems( $search, [] ) ) === 0 )
165
+		if (count($productManager->searchItems($search, [])) === 0)
166 166
 		{
167
-			$msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) );
168
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
167
+			$msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId));
168
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
169 169
 		}
170 170
 	}
171 171
 
@@ -175,41 +175,41 @@  discard block
 block discarded – undo
175 175
 	 *
176 176
 	 * @param string $type Basket type
177 177
 	 */
178
-	protected function checkLocale( $type )
178
+	protected function checkLocale($type)
179 179
 	{
180 180
 		$errors = [];
181 181
 		$context = $this->getContext();
182 182
 		$session = $context->getSession();
183 183
 		$locale = $this->get()->getLocale();
184 184
 
185
-		$localeStr = $session->get( 'aimeos/basket/locale' );
185
+		$localeStr = $session->get('aimeos/basket/locale');
186 186
 		$localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId();
187 187
 
188
-		if( $localeStr !== null && $localeStr !== $localeKey )
188
+		if ($localeStr !== null && $localeStr !== $localeKey)
189 189
 		{
190
-			$locParts = explode( '|', $localeStr );
191
-			$locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' );
192
-			$locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' );
193
-			$locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' );
190
+			$locParts = explode('|', $localeStr);
191
+			$locSite = (isset($locParts[0]) ? $locParts[0] : '');
192
+			$locLanguage = (isset($locParts[1]) ? $locParts[1] : '');
193
+			$locCurrency = (isset($locParts[2]) ? $locParts[2] : '');
194 194
 
195
-			$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
196
-			$locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false );
195
+			$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
196
+			$locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false);
197 197
 
198 198
 			$context = clone $context;
199
-			$context->setLocale( $locale );
199
+			$context->setLocale($locale);
200 200
 
201
-			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' );
202
-			$basket = $manager->getSession( $type );
201
+			$manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base');
202
+			$basket = $manager->getSession($type);
203 203
 
204
-			$this->copyAddresses( $basket, $errors, $localeKey );
205
-			$this->copyServices( $basket, $errors );
206
-			$this->copyProducts( $basket, $errors, $localeKey );
207
-			$this->copyCoupons( $basket, $errors, $localeKey );
204
+			$this->copyAddresses($basket, $errors, $localeKey);
205
+			$this->copyServices($basket, $errors);
206
+			$this->copyProducts($basket, $errors, $localeKey);
207
+			$this->copyCoupons($basket, $errors, $localeKey);
208 208
 
209
-			$manager->setSession( $basket, $type );
209
+			$manager->setSession($basket, $type);
210 210
 		}
211 211
 
212
-		$session->set( 'aimeos/basket/locale', $localeKey );
212
+		$session->set('aimeos/basket/locale', $localeKey);
213 213
 	}
214 214
 
215 215
 
@@ -221,20 +221,20 @@  discard block
 block discarded – undo
221 221
 	 * @param string $localeKey Unique identifier of the site, language and currency
222 222
 	 * @return array Associative list of errors occured
223 223
 	 */
224
-	protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
224
+	protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
225 225
 	{
226
-		foreach( $basket->getAddresses() as $type => $item )
226
+		foreach ($basket->getAddresses() as $type => $item)
227 227
 		{
228 228
 			try
229 229
 			{
230
-				$this->setAddress( $type, $item->toArray() );
231
-				$basket->deleteAddress( $type );
230
+				$this->setAddress($type, $item->toArray());
231
+				$basket->deleteAddress($type);
232 232
 			}
233
-			catch( \Exception $e )
233
+			catch (\Exception $e)
234 234
 			{
235 235
 				$logger = $this->getContext()->getLogger();
236 236
 				$str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s';
237
-				$logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
237
+				$logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
238 238
 				$errors['address'][$type] = $e->getMessage();
239 239
 			}
240 240
 		}
@@ -251,20 +251,20 @@  discard block
 block discarded – undo
251 251
 	 * @param string $localeKey Unique identifier of the site, language and currency
252 252
 	 * @return array Associative list of errors occured
253 253
 	 */
254
-	protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
254
+	protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
255 255
 	{
256
-		foreach( $basket->getCoupons() as $code => $list )
256
+		foreach ($basket->getCoupons() as $code => $list)
257 257
 		{
258 258
 			try
259 259
 			{
260
-				$this->addCoupon( $code );
261
-				$basket->deleteCoupon( $code, true );
260
+				$this->addCoupon($code);
261
+				$basket->deleteCoupon($code, true);
262 262
 			}
263
-			catch( \Exception $e )
263
+			catch (\Exception $e)
264 264
 			{
265 265
 				$logger = $this->getContext()->getLogger();
266 266
 				$str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s';
267
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
267
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
268 268
 				$errors['coupon'][$code] = $e->getMessage();
269 269
 			}
270 270
 		}
@@ -281,11 +281,11 @@  discard block
 block discarded – undo
281 281
 	 * @param string $localeKey Unique identifier of the site, language and currency
282 282
 	 * @return array Associative list of errors occured
283 283
 	 */
284
-	protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey )
284
+	protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey)
285 285
 	{
286
-		foreach( $basket->getProducts() as $pos => $product )
286
+		foreach ($basket->getProducts() as $pos => $product)
287 287
 		{
288
-			if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) {
288
+			if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) {
289 289
 				continue;
290 290
 			}
291 291
 
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
 			{
294 294
 				$attrIds = [];
295 295
 
296
-				foreach( $product->getAttributes() as $attrItem ) {
296
+				foreach ($product->getAttributes() as $attrItem) {
297 297
 					$attrIds[$attrItem->getType()][] = $attrItem->getAttributeId();
298 298
 				}
299 299
 
@@ -301,22 +301,22 @@  discard block
 block discarded – undo
301 301
 					$product->getProductId(),
302 302
 					$product->getQuantity(),
303 303
 					$product->getStockType(),
304
-					$this->getValue( $attrIds, 'variant', [] ),
305
-					$this->getValue( $attrIds, 'config', [] ),
306
-					$this->getValue( $attrIds, 'hidden', [] ),
307
-					$this->getValue( $attrIds, 'custom', [] )
304
+					$this->getValue($attrIds, 'variant', []),
305
+					$this->getValue($attrIds, 'config', []),
306
+					$this->getValue($attrIds, 'hidden', []),
307
+					$this->getValue($attrIds, 'custom', [])
308 308
 				);
309 309
 
310
-				$basket->deleteProduct( $pos );
310
+				$basket->deleteProduct($pos);
311 311
 			}
312
-			catch( \Exception $e )
312
+			catch (\Exception $e)
313 313
 			{
314 314
 				$code = $product->getProductCode();
315 315
 				$logger = $this->getContext()->getLogger();
316 316
 				$errors['product'][$pos] = $e->getMessage();
317 317
 
318 318
 				$str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s';
319
-				$logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO );
319
+				$logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO);
320 320
 			}
321 321
 		}
322 322
 
@@ -331,24 +331,24 @@  discard block
 block discarded – undo
331 331
 	 * @param array $errors Associative list of previous errors
332 332
 	 * @return array Associative list of errors occured
333 333
 	 */
334
-	protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors )
334
+	protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors)
335 335
 	{
336
-		foreach( $basket->getServices() as $type => $list )
336
+		foreach ($basket->getServices() as $type => $list)
337 337
 		{
338
-			foreach( $list as $item )
338
+			foreach ($list as $item)
339 339
 			{
340 340
 				try
341 341
 				{
342 342
 					$attributes = [];
343 343
 
344
-					foreach( $item->getAttributes() as $attrItem ) {
344
+					foreach ($item->getAttributes() as $attrItem) {
345 345
 						$attributes[$attrItem->getCode()] = $attrItem->getValue();
346 346
 					}
347 347
 
348
-					$this->addService( $type, $item->getServiceId(), $attributes );
349
-					$basket->deleteService( $type );
348
+					$this->addService($type, $item->getServiceId(), $attributes);
349
+					$basket->deleteService($type);
350 350
 				}
351
-				catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically
351
+				catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically
352 352
 			}
353 353
 		}
354 354
 
@@ -368,36 +368,36 @@  discard block
 block discarded – undo
368 368
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
369 369
 	 * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead
370 370
 	 */
371
-	protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
372
-			array $attributeIds, $type, array $attributeValues = [] )
371
+	protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity,
372
+			array $attributeIds, $type, array $attributeValues = [])
373 373
 	{
374
-		if( empty( $attributeIds ) ) {
374
+		if (empty($attributeIds)) {
375 375
 			return [];
376 376
 		}
377 377
 
378
-		$attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId();
379
-		$this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds );
378
+		$attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId();
379
+		$this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds);
380 380
 
381 381
 		$list = [];
382 382
 		$context = $this->getContext();
383 383
 
384
-		$priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' );
385
-		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' );
384
+		$priceManager = \Aimeos\MShop\Factory::createManager($context, 'price');
385
+		$orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute');
386 386
 
387
-		foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem )
387
+		foreach ($this->getAttributes($attributeIds) as $id => $attrItem)
388 388
 		{
389
-			$prices = $attrItem->getRefItems( 'price', 'default', 'default' );
389
+			$prices = $attrItem->getRefItems('price', 'default', 'default');
390 390
 
391
-			if( !empty( $prices ) ) {
392
-				$price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) );
391
+			if (!empty($prices)) {
392
+				$price->addItem($priceManager->getLowestPrice($prices, $quantity));
393 393
 			}
394 394
 
395 395
 			$item = $orderProductAttributeManager->createItem();
396
-			$item->copyFrom( $attrItem );
397
-			$item->setType( $type );
396
+			$item->copyFrom($attrItem);
397
+			$item->setType($type);
398 398
 
399
-			if( isset( $attributeValues[$id] ) ) {
400
-				$item->setValue( $attributeValues[$id] );
399
+			if (isset($attributeValues[$id])) {
400
+				$item->setValue($attributeValues[$id]);
401 401
 			}
402 402
 
403 403
 			$list[] = $item;
@@ -415,31 +415,31 @@  discard block
 block discarded – undo
415 415
 	 * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface
416 416
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one
417 417
 	 */
418
-	protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) )
418
+	protected function getAttributes(array $attributeIds, array $domains = array('price', 'text'))
419 419
 	{
420
-		if( empty( $attributeIds ) ) {
420
+		if (empty($attributeIds)) {
421 421
 			return [];
422 422
 		}
423 423
 
424
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
424
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
425 425
 
426
-		$search = $attributeManager->createSearch( true );
426
+		$search = $attributeManager->createSearch(true);
427 427
 		$expr = array(
428
-			$search->compare( '==', 'attribute.id', $attributeIds ),
428
+			$search->compare('==', 'attribute.id', $attributeIds),
429 429
 			$search->getConditions(),
430 430
 		);
431
-		$search->setConditions( $search->combine( '&&', $expr ) );
432
-		$search->setSlice( 0, 0x7fffffff );
431
+		$search->setConditions($search->combine('&&', $expr));
432
+		$search->setSlice(0, 0x7fffffff);
433 433
 
434
-		$attrItems = $attributeManager->searchItems( $search, $domains );
434
+		$attrItems = $attributeManager->searchItems($search, $domains);
435 435
 
436
-		if( count( $attrItems ) !== count( $attributeIds ) )
436
+		if (count($attrItems) !== count($attributeIds))
437 437
 		{
438
-			$expected = implode( ',', $attributeIds );
439
-			$actual = implode( ',', array_keys( $attrItems ) );
440
-			$msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected );
438
+			$expected = implode(',', $attributeIds);
439
+			$actual = implode(',', array_keys($attrItems));
440
+			$msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected);
441 441
 
442
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
442
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
443 443
 		}
444 444
 
445 445
 		return $attrItems;
@@ -452,31 +452,31 @@  discard block
 block discarded – undo
452 452
 	 * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items
453 453
 	 * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values
454 454
 	 */
455
-	protected function getAttributeItems( array $orderAttributes )
455
+	protected function getAttributeItems(array $orderAttributes)
456 456
 	{
457
-		if( empty( $orderAttributes ) ) {
457
+		if (empty($orderAttributes)) {
458 458
 			return [];
459 459
 		}
460 460
 
461
-		$attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' );
462
-		$search = $attributeManager->createSearch( true );
461
+		$attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute');
462
+		$search = $attributeManager->createSearch(true);
463 463
 		$expr = [];
464 464
 
465
-		foreach( $orderAttributes as $item )
465
+		foreach ($orderAttributes as $item)
466 466
 		{
467 467
 			$tmp = array(
468
-				$search->compare( '==', 'attribute.domain', 'product' ),
469
-				$search->compare( '==', 'attribute.code', $item->getValue() ),
470
-				$search->compare( '==', 'attribute.type.domain', 'product' ),
471
-				$search->compare( '==', 'attribute.type.code', $item->getCode() ),
472
-				$search->compare( '>', 'attribute.type.status', 0 ),
468
+				$search->compare('==', 'attribute.domain', 'product'),
469
+				$search->compare('==', 'attribute.code', $item->getValue()),
470
+				$search->compare('==', 'attribute.type.domain', 'product'),
471
+				$search->compare('==', 'attribute.type.code', $item->getCode()),
472
+				$search->compare('>', 'attribute.type.status', 0),
473 473
 				$search->getConditions(),
474 474
 			);
475
-			$expr[] = $search->combine( '&&', $tmp );
475
+			$expr[] = $search->combine('&&', $tmp);
476 476
 		}
477 477
 
478
-		$search->setConditions( $search->combine( '||', $expr ) );
479
-		return $attributeManager->searchItems( $search, array( 'price' ) );
478
+		$search->setConditions($search->combine('||', $expr));
479
+		return $attributeManager->searchItems($search, array('price'));
480 480
 	}
481 481
 
482 482
 
@@ -491,23 +491,23 @@  discard block
 block discarded – undo
491 491
 	 * @throws \Aimeos\Controller\Frontend\Basket\Exception
492 492
 	 * @deprecated Use getItem() or findItem() instead
493 493
 	 */
494
-	protected function getDomainItem( $domain, $key, $value, array $ref )
494
+	protected function getDomainItem($domain, $key, $value, array $ref)
495 495
 	{
496
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain );
496
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain);
497 497
 
498
-		$search = $manager->createSearch( true );
498
+		$search = $manager->createSearch(true);
499 499
 		$expr = array(
500
-			$search->compare( '==', $key, $value ),
500
+			$search->compare('==', $key, $value),
501 501
 			$search->getConditions(),
502 502
 		);
503
-		$search->setConditions( $search->combine( '&&', $expr ) );
503
+		$search->setConditions($search->combine('&&', $expr));
504 504
 
505
-		$result = $manager->searchItems( $search, $ref );
505
+		$result = $manager->searchItems($search, $ref);
506 506
 
507
-		if( ( $item = reset( $result ) ) === false )
507
+		if (($item = reset($result)) === false)
508 508
 		{
509
-			$msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key );
510
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
509
+			$msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key);
510
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
511 511
 		}
512 512
 
513 513
 		return $item;
@@ -523,24 +523,24 @@  discard block
 block discarded – undo
523 523
 	 * @param array $quantities Associative list of attribute IDs as keys and their quantities as values
524 524
 	 * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface
525 525
 	 */
526
-	protected function getOrderProductAttributes( $type, array $ids, array $values = [], array $quantities = [] )
526
+	protected function getOrderProductAttributes($type, array $ids, array $values = [], array $quantities = [])
527 527
 	{
528
-		if( empty( $ids ) ) {
528
+		if (empty($ids)) {
529 529
 			return [];
530 530
 		}
531 531
 
532 532
 		$list = [];
533
-		$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' );
533
+		$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute');
534 534
 
535
-		foreach( $this->getAttributes( $ids ) as $id => $attrItem )
535
+		foreach ($this->getAttributes($ids) as $id => $attrItem)
536 536
 		{
537 537
 			$item = $manager->createItem();
538
-			$item->copyFrom( $attrItem );
539
-			$item->setType( $type );
540
-			$item->setQuantity( isset( $quantities[$id] ) ? $quantities[$id] : 1 );
538
+			$item->copyFrom($attrItem);
539
+			$item->setType($type);
540
+			$item->setQuantity(isset($quantities[$id]) ? $quantities[$id] : 1);
541 541
 
542
-			if( isset( $values[$id] ) ) {
543
-				$item->setValue( $values[$id] );
542
+			if (isset($values[$id])) {
543
+				$item->setValue($values[$id]);
544 544
 			}
545 545
 
546 546
 			$list[] = $item;
@@ -557,21 +557,21 @@  discard block
 block discarded – undo
557 557
 	 * @param string $code Code of the list type
558 558
 	 * @return \Aimeos\MShop\Common\Item\Type\Iface List type item
559 559
 	 */
560
-	protected function getProductListTypeItem( $domain, $code )
560
+	protected function getProductListTypeItem($domain, $code)
561 561
 	{
562
-		if( empty( $this->listTypeItems ) )
562
+		if (empty($this->listTypeItems))
563 563
 		{
564
-			$manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' );
564
+			$manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type');
565 565
 
566
-			foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) {
567
-				$this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item;
566
+			foreach ($manager->searchItems($manager->createSearch(true)) as $item) {
567
+				$this->listTypeItems[$item->getDomain()][$item->getCode()] = $item;
568 568
 			}
569 569
 		}
570 570
 
571
-		if( !isset( $this->listTypeItems[$domain][$code] ) )
571
+		if (!isset($this->listTypeItems[$domain][$code]))
572 572
 		{
573
-			$msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code );
574
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg );
573
+			$msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code);
574
+			throw new \Aimeos\Controller\Frontend\Basket\Exception($msg);
575 575
 		}
576 576
 
577 577
 		return $this->listTypeItems[$domain][$code];
@@ -586,43 +586,43 @@  discard block
 block discarded – undo
586 586
 	 * @param array $domains Names of the domain items that should be fetched too
587 587
 	 * @return array List of products matching the given attributes
588 588
 	 */
589
-	protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
590
-			array $domains = array( 'attribute', 'media', 'price', 'text' ) )
589
+	protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds,
590
+			array $domains = array('attribute', 'media', 'price', 'text'))
591 591
 	{
592 592
 		$subProductIds = [];
593
-		foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) {
593
+		foreach ($productItem->getRefItems('product', 'default', 'default') as $item) {
594 594
 			$subProductIds[] = $item->getId();
595 595
 		}
596 596
 
597
-		if( count( $subProductIds ) === 0 ) {
597
+		if (count($subProductIds) === 0) {
598 598
 			return [];
599 599
 		}
600 600
 
601
-		$productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' );
602
-		$search = $productManager->createSearch( true );
601
+		$productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product');
602
+		$search = $productManager->createSearch(true);
603 603
 
604 604
 		$expr = array(
605
-			$search->compare( '==', 'product.id', $subProductIds ),
605
+			$search->compare('==', 'product.id', $subProductIds),
606 606
 			$search->getConditions(),
607 607
 		);
608 608
 
609
-		if( count( $variantAttributeIds ) > 0 )
609
+		if (count($variantAttributeIds) > 0)
610 610
 		{
611
-			foreach( $variantAttributeIds as $key => $id ) {
611
+			foreach ($variantAttributeIds as $key => $id) {
612 612
 				$variantAttributeIds[$key] = (string) $id;
613 613
 			}
614 614
 
615
-			$listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' );
615
+			$listTypeItem = $this->getProductListTypeItem('attribute', 'variant');
616 616
 
617
-			$param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds );
618
-			$cmpfunc = $search->createFunction( 'product.contains', $param );
617
+			$param = array('attribute', $listTypeItem->getId(), $variantAttributeIds);
618
+			$cmpfunc = $search->createFunction('product.contains', $param);
619 619
 
620
-			$expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) );
620
+			$expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds));
621 621
 		}
622 622
 
623
-		$search->setConditions( $search->combine( '&&', $expr ) );
623
+		$search->setConditions($search->combine('&&', $expr));
624 624
 
625
-		return $productManager->searchItems( $search, $domains );
625
+		return $productManager->searchItems($search, $domains);
626 626
 	}
627 627
 
628 628
 
@@ -634,9 +634,9 @@  discard block
 block discarded – undo
634 634
 	 * @param mixed $default Default value if no value is available for the given name
635 635
 	 * @return mixed Value from the array or default value
636 636
 	 */
637
-	protected function getValue( array $values, $name, $default = null )
637
+	protected function getValue(array $values, $name, $default = null)
638 638
 	{
639
-		if( isset( $values[$name] ) ) {
639
+		if (isset($values[$name])) {
640 640
 			return $values[$name];
641 641
 		}
642 642
 
Please login to merge, or discard this patch.