Completed
Push — master ( 095350...afa75e )
by Aimeos
07:31
created
controller/frontend/src/Controller/Frontend/Basket/Decorator/Select.php 2 patches
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 = $context->getI18n()->dt( 'controller/frontend', 'No unique article found for selected attributes and product ID "%1$s"' );
123
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) );
122
+			$msg = $context->getI18n()->dt('controller/frontend', 'No unique article found for selected attributes and product ID "%1$s"');
123
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $productItem->getId()));
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 = $context->getI18n()->dt( 'controller/frontend', 'No article found for selected attributes and product ID "%1$s"' );
157
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) );
156
+			$msg = $context->getI18n()->dt('controller/frontend', 'No article found for selected attributes and product ID "%1$s"');
157
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $productItem->getId()));
158 158
 		}
159 159
 
160 160
 		return $attr;
Please login to merge, or discard this patch.
Braces   +6 added lines, -4 removed lines patch added patch discarded remove patch
@@ -121,10 +121,11 @@  discard block
 block discarded – undo
121 121
 		{
122 122
 			$msg = $context->getI18n()->dt( 'controller/frontend', 'No unique article found for selected attributes and product ID "%1$s"' );
123 123
 			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) );
124
-		}
125
-		else if( ( $result = reset( $productItems ) ) !== false ) // count == 1
124
+		} else if( ( $result = reset( $productItems ) ) !== false ) {
125
+			// count == 1
126 126
 		{
127 127
 			$productItem = $result;
128
+		}
128 129
 			$orderBaseProductItem->setProductCode( $productItem->getCode() );
129 130
 
130 131
 			$subprices = $productItem->getRefItems( 'price', 'default', 'default' );
@@ -150,10 +151,11 @@  discard block
 block discarded – undo
150 151
 
151 152
 				$attr[] = $orderAttributeItem;
152 153
 			}
153
-		}
154
-		else if( $requireVariant != false ) // count == 0
154
+		} else if( $requireVariant != false ) {
155
+			// count == 0
155 156
 		{
156 157
 			$msg = $context->getI18n()->dt( 'controller/frontend', 'No article found for selected attributes and product ID "%1$s"' );
158
+		}
157 159
 			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $productItem->getId() ) );
158 160
 		}
159 161
 
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,27 +36,27 @@
 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
-		$catalogListManager = \Aimeos\MShop\Factory::createManager( $context, 'catalog/lists' );
43
+		$catalogListManager = \Aimeos\MShop\Factory::createManager($context, 'catalog/lists');
44 44
 
45
-		$search = $catalogListManager->createSearch( true );
45
+		$search = $catalogListManager->createSearch(true);
46 46
 		$expr = array(
47
-			$search->compare( '==', 'catalog.lists.domain', 'product' ),
48
-			$search->compare( '==', 'catalog.lists.refid', $prodid ),
47
+			$search->compare('==', 'catalog.lists.domain', 'product'),
48
+			$search->compare('==', 'catalog.lists.refid', $prodid),
49 49
 			$search->getConditions()
50 50
 		);
51
-		$search->setConditions( $search->combine( '&&', $expr ) );
52
-		$search->setSlice( 0, 1 );
51
+		$search->setConditions($search->combine('&&', $expr));
52
+		$search->setSlice(0, 1);
53 53
 
54
-		$result = $catalogListManager->searchItems( $search );
54
+		$result = $catalogListManager->searchItems($search);
55 55
 
56
-		if( reset( $result ) === false )
56
+		if (reset($result) === false)
57 57
 		{
58
-			$msg = $context->getI18n()->dt( 'controller/frontend', 'Adding product with ID "%1$s" is not allowed' );
59
-			throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( $msg, $prodid ) );
58
+			$msg = $context->getI18n()->dt('controller/frontend', 'Adding product with ID "%1$s" is not allowed');
59
+			throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf($msg, $prodid));
60 60
 		}
61 61
 
62 62
 		$this->getController()->addProduct(
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 = $context->getI18n()->dt( 'controller/frontend', 'Class "%1$s" does not implement interface "%2$s"' );
39
-			throw new \Aimeos\Controller\Frontend\Exception( sprintf( $msg, get_class( $controller ), $iface ) );
38
+			$msg = $context->getI18n()->dt('controller/frontend', 'Class "%1$s" does not implement interface "%2$s"');
39
+			throw new \Aimeos\Controller\Frontend\Exception(sprintf($msg, get_class($controller), $iface));
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\Item\Base\Base::PARTS_ALL, $default = true )
126
+	public function load($id, $parts = \Aimeos\MShop\Order\Item\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.