@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
32 | 32 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
33 | 33 | */ |
34 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
34 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
35 | 35 | { |
36 | 36 | $this->context = $context; |
37 | 37 | $this->controller = $controller; |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * @return mixed Returns the value of the called method |
47 | 47 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
48 | 48 | */ |
49 | - public function __call( $name, array $param ) |
|
49 | + public function __call($name, array $param) |
|
50 | 50 | { |
51 | - if( ( $result = call_user_func_array( array( $this->controller, $name ), $param ) ) === false ) |
|
51 | + if (($result = call_user_func_array(array($this->controller, $name), $param)) === false) |
|
52 | 52 | { |
53 | - $cntl = get_class( $this->controller ); |
|
54 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Unable to call method "%1$s::%2$s"', $cntl, $name ) ); |
|
53 | + $cntl = get_class($this->controller); |
|
54 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Unable to call method "%1$s::%2$s"', $cntl, $name)); |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | return $result; |
@@ -32,9 +32,9 @@ |
||
32 | 32 | * @param \Exception $previous The previous exception used for the exception chaining. |
33 | 33 | * @param array $list The associative list of errors and their messages when several errors occured |
34 | 34 | */ |
35 | - public function __construct( $msg = '', $code = 0, \Exception $previous = null, array $list = array() ) |
|
35 | + public function __construct($msg = '', $code = 0, \Exception $previous = null, array $list = array()) |
|
36 | 36 | { |
37 | - parent::__construct( $msg, $code, $previous ); |
|
37 | + parent::__construct($msg, $code, $previous); |
|
38 | 38 | |
39 | 39 | $this->list = $list; |
40 | 40 | } |
@@ -288,17 +288,14 @@ discard block |
||
288 | 288 | { |
289 | 289 | $address->copyFrom( $value ); |
290 | 290 | $this->basket->setAddress( $address, $type ); |
291 | - } |
|
292 | - else if( is_array( $value ) ) |
|
291 | + } else if( is_array( $value ) ) |
|
293 | 292 | { |
294 | 293 | $this->setAddressFromArray( $address, $value ); |
295 | 294 | $this->basket->setAddress( $address, $type ); |
296 | - } |
|
297 | - else if( $value === null ) |
|
295 | + } else if( $value === null ) |
|
298 | 296 | { |
299 | 297 | $this->basket->deleteAddress( $type ); |
300 | - } |
|
301 | - else |
|
298 | + } else |
|
302 | 299 | { |
303 | 300 | throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
304 | 301 | } |
@@ -564,8 +561,7 @@ discard block |
||
564 | 561 | { |
565 | 562 | $this->setAddress( $type, $item->toArray() ); |
566 | 563 | $basket->deleteAddress( $type ); |
567 | - } |
|
568 | - catch( \Exception $e ) |
|
564 | + } catch( \Exception $e ) |
|
569 | 565 | { |
570 | 566 | $logger = $this->getContext()->getLogger(); |
571 | 567 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -594,8 +590,7 @@ discard block |
||
594 | 590 | { |
595 | 591 | $this->addCoupon( $code ); |
596 | 592 | $basket->deleteCoupon( $code, true ); |
597 | - } |
|
598 | - catch( \Exception $e ) |
|
593 | + } catch( \Exception $e ) |
|
599 | 594 | { |
600 | 595 | $logger = $this->getContext()->getLogger(); |
601 | 596 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
@@ -644,8 +639,7 @@ discard block |
||
644 | 639 | ); |
645 | 640 | |
646 | 641 | $basket->deleteProduct( $pos ); |
647 | - } |
|
648 | - catch( \Exception $e ) |
|
642 | + } catch( \Exception $e ) |
|
649 | 643 | { |
650 | 644 | $code = $product->getProductCode(); |
651 | 645 | $logger = $this->getContext()->getLogger(); |
@@ -680,8 +674,7 @@ discard block |
||
680 | 674 | |
681 | 675 | $this->setService( $type, $item->getServiceId(), $attributes ); |
682 | 676 | $basket->deleteService( $type ); |
683 | - } |
|
684 | - catch( \Exception $e ) {; } // Don't notify the user as appropriate services can be added automatically |
|
677 | + } catch( \Exception $e ) {; } // Don't notify the user as appropriate services can be added automatically |
|
685 | 678 | } |
686 | 679 | |
687 | 680 | return $errors; |
@@ -1087,10 +1080,11 @@ discard block |
||
1087 | 1080 | { |
1088 | 1081 | $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
1089 | 1082 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
1090 | - } |
|
1091 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
1083 | + } else if( ( $result = reset( $productItems ) ) !== false ) { |
|
1084 | + // count == 1 |
|
1092 | 1085 | { |
1093 | 1086 | $productItem = $result; |
1087 | + } |
|
1094 | 1088 | $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
1095 | 1089 | |
1096 | 1090 | $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
@@ -1110,10 +1104,11 @@ discard block |
||
1110 | 1104 | |
1111 | 1105 | $attr[] = $orderAttributeItem; |
1112 | 1106 | } |
1113 | - } |
|
1114 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
1107 | + } else if( !isset( $options['variant'] ) || $options['variant'] != false ) { |
|
1108 | + // count == 0 |
|
1115 | 1109 | { |
1116 | 1110 | $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
1111 | + } |
|
1117 | 1112 | throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
1118 | 1113 | } |
1119 | 1114 |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
31 | 31 | * connections, logger, session, etc. |
32 | 32 | */ |
33 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
33 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
34 | 34 | { |
35 | - parent::__construct( $context ); |
|
35 | + parent::__construct($context); |
|
36 | 36 | |
37 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
37 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
38 | 38 | $this->basket = $this->domainManager->getSession(); |
39 | 39 | |
40 | 40 | $this->checkLocale(); |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | public function clear() |
48 | 48 | { |
49 | 49 | $this->basket = $this->domainManager->createItem(); |
50 | - $this->domainManager->setSession( $this->basket ); |
|
50 | + $this->domainManager->setSession($this->basket); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
@@ -82,47 +82,47 @@ discard block |
||
82 | 82 | * @param string $warehouse Unique code of the warehouse to deliver the products from |
83 | 83 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
84 | 84 | */ |
85 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
85 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
86 | 86 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
87 | - $warehouse = 'default' ) |
|
87 | + $warehouse = 'default') |
|
88 | 88 | { |
89 | 89 | $context = $this->getContext(); |
90 | 90 | |
91 | - $productItem = $this->getDomainItem( 'product', 'product.id', $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
91 | + $productItem = $this->getDomainItem('product', 'product.id', $prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
92 | 92 | |
93 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
94 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
95 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
96 | - $orderBaseProductItem->setWarehouseCode( $warehouse ); |
|
93 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
94 | + $orderBaseProductItem->copyFrom($productItem); |
|
95 | + $orderBaseProductItem->setQuantity($quantity); |
|
96 | + $orderBaseProductItem->setWarehouseCode($warehouse); |
|
97 | 97 | |
98 | 98 | $attr = array(); |
99 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
99 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
100 | 100 | |
101 | - switch( $productItem->getType() ) |
|
101 | + switch ($productItem->getType()) |
|
102 | 102 | { |
103 | 103 | case 'select': |
104 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
104 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
105 | 105 | break; |
106 | 106 | case 'bundle': |
107 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $warehouse ); |
|
107 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $warehouse); |
|
108 | 108 | break; |
109 | 109 | } |
110 | 110 | |
111 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
112 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
111 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
112 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
113 | 113 | |
114 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
115 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
116 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
114 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
115 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
116 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
117 | 117 | |
118 | 118 | // remove product rebate of original price in favor to rebates granted for the order |
119 | - $price->setRebate( '0.00' ); |
|
119 | + $price->setRebate('0.00'); |
|
120 | 120 | |
121 | - $orderBaseProductItem->setPrice( $price ); |
|
122 | - $orderBaseProductItem->setAttributes( $attr ); |
|
121 | + $orderBaseProductItem->setPrice($price); |
|
122 | + $orderBaseProductItem->setAttributes($attr); |
|
123 | 123 | |
124 | - $this->basket->addProduct( $orderBaseProductItem ); |
|
125 | - $this->domainManager->setSession( $this->basket ); |
|
124 | + $this->basket->addProduct($orderBaseProductItem); |
|
125 | + $this->domainManager->setSession($this->basket); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | |
@@ -131,18 +131,18 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param integer $position Position number (key) of the order product item |
133 | 133 | */ |
134 | - public function deleteProduct( $position ) |
|
134 | + public function deleteProduct($position) |
|
135 | 135 | { |
136 | - $product = $this->basket->getProduct( $position ); |
|
136 | + $product = $this->basket->getProduct($position); |
|
137 | 137 | |
138 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
138 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
139 | 139 | { |
140 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
141 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
140 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
141 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
142 | 142 | } |
143 | 143 | |
144 | - $this->basket->deleteProduct( $position ); |
|
145 | - $this->domainManager->setSession( $this->basket ); |
|
144 | + $this->basket->deleteProduct($position); |
|
145 | + $this->domainManager->setSession($this->basket); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | |
@@ -155,36 +155,36 @@ discard block |
||
155 | 155 | * The 'stock'=>false option allows adding products without being in stock. |
156 | 156 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
157 | 157 | */ |
158 | - public function editProduct( $position, $quantity, array $options = array(), |
|
159 | - array $configAttributeCodes = array() ) |
|
158 | + public function editProduct($position, $quantity, array $options = array(), |
|
159 | + array $configAttributeCodes = array()) |
|
160 | 160 | { |
161 | - $product = $this->basket->getProduct( $position ); |
|
162 | - $product->setQuantity( $quantity ); // Enforce check immediately |
|
161 | + $product = $this->basket->getProduct($position); |
|
162 | + $product->setQuantity($quantity); // Enforce check immediately |
|
163 | 163 | |
164 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
164 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
165 | 165 | { |
166 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
167 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
166 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
167 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | $attributes = $product->getAttributes(); |
171 | - foreach( $attributes as $key => $attribute ) |
|
171 | + foreach ($attributes as $key => $attribute) |
|
172 | 172 | { |
173 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
174 | - unset( $attributes[$key] ); |
|
173 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
174 | + unset($attributes[$key]); |
|
175 | 175 | } |
176 | 176 | } |
177 | - $product->setAttributes( $attributes ); |
|
177 | + $product->setAttributes($attributes); |
|
178 | 178 | |
179 | - $productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) ); |
|
180 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
179 | + $productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text')); |
|
180 | + $prices = $productItem->getRefItems('price', 'default'); |
|
181 | 181 | |
182 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
182 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
183 | 183 | |
184 | - $this->basket->deleteProduct( $position ); |
|
185 | - $this->basket->addProduct( $product, $position ); |
|
184 | + $this->basket->deleteProduct($position); |
|
185 | + $this->basket->addProduct($product, $position); |
|
186 | 186 | |
187 | - $this->domainManager->setSession( $this->basket ); |
|
187 | + $this->domainManager->setSession($this->basket); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | |
@@ -194,50 +194,50 @@ discard block |
||
194 | 194 | * @param string $code Coupon code entered by the user |
195 | 195 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
196 | 196 | */ |
197 | - public function addCoupon( $code ) |
|
197 | + public function addCoupon($code) |
|
198 | 198 | { |
199 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
200 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
199 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
200 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
201 | 201 | |
202 | 202 | |
203 | - $search = $codeManager->createSearch( true ); |
|
203 | + $search = $codeManager->createSearch(true); |
|
204 | 204 | $expr = array( |
205 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
205 | + $search->compare('==', 'coupon.code.code', $code), |
|
206 | 206 | $search->getConditions(), |
207 | 207 | ); |
208 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
209 | - $search->setSlice( 0, 1 ); |
|
208 | + $search->setConditions($search->combine('&&', $expr)); |
|
209 | + $search->setSlice(0, 1); |
|
210 | 210 | |
211 | - $result = $codeManager->searchItems( $search ); |
|
211 | + $result = $codeManager->searchItems($search); |
|
212 | 212 | |
213 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
214 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
213 | + if (($codeItem = reset($result)) === false) { |
|
214 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | |
218 | - $search = $manager->createSearch( true ); |
|
218 | + $search = $manager->createSearch(true); |
|
219 | 219 | $expr = array( |
220 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
220 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
221 | 221 | $search->getConditions(), |
222 | 222 | ); |
223 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
224 | - $search->setSlice( 0, 1 ); |
|
223 | + $search->setConditions($search->combine('&&', $expr)); |
|
224 | + $search->setSlice(0, 1); |
|
225 | 225 | |
226 | - $result = $manager->searchItems( $search ); |
|
226 | + $result = $manager->searchItems($search); |
|
227 | 227 | |
228 | - if( ( $item = reset( $result ) ) === false ) { |
|
229 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
228 | + if (($item = reset($result)) === false) { |
|
229 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | |
233 | - $provider = $manager->getProvider( $item, $code ); |
|
233 | + $provider = $manager->getProvider($item, $code); |
|
234 | 234 | |
235 | - if( $provider->isAvailable( $this->basket ) !== true ) { |
|
236 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
235 | + if ($provider->isAvailable($this->basket) !== true) { |
|
236 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
237 | 237 | } |
238 | 238 | |
239 | - $provider->addCoupon( $this->basket ); |
|
240 | - $this->domainManager->setSession( $this->basket ); |
|
239 | + $provider->addCoupon($this->basket); |
|
240 | + $this->domainManager->setSession($this->basket); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | * @param string $code Coupon code entered by the user |
248 | 248 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
249 | 249 | */ |
250 | - public function deleteCoupon( $code ) |
|
250 | + public function deleteCoupon($code) |
|
251 | 251 | { |
252 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
252 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
253 | 253 | |
254 | 254 | $search = $manager->createSearch(); |
255 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
256 | - $search->setSlice( 0, 1 ); |
|
255 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
256 | + $search->setSlice(0, 1); |
|
257 | 257 | |
258 | - $result = $manager->searchItems( $search ); |
|
258 | + $result = $manager->searchItems($search); |
|
259 | 259 | |
260 | - if( ( $item = reset( $result ) ) === false ) { |
|
261 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
260 | + if (($item = reset($result)) === false) { |
|
261 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
262 | 262 | } |
263 | 263 | |
264 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->basket ); |
|
265 | - $this->domainManager->setSession( $this->basket ); |
|
264 | + $manager->getProvider($item, $code)->deleteCoupon($this->basket); |
|
265 | + $this->domainManager->setSession($this->basket); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -274,31 +274,31 @@ discard block |
||
274 | 274 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
275 | 275 | * if one of the keys is invalid when using an array with key/value pairs |
276 | 276 | */ |
277 | - public function setAddress( $type, $value ) |
|
277 | + public function setAddress($type, $value) |
|
278 | 278 | { |
279 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
280 | - $address->setType( $type ); |
|
279 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
280 | + $address->setType($type); |
|
281 | 281 | |
282 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
282 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
283 | 283 | { |
284 | - $address->copyFrom( $value ); |
|
285 | - $this->basket->setAddress( $address, $type ); |
|
284 | + $address->copyFrom($value); |
|
285 | + $this->basket->setAddress($address, $type); |
|
286 | 286 | } |
287 | - else if( is_array( $value ) ) |
|
287 | + else if (is_array($value)) |
|
288 | 288 | { |
289 | - $this->setAddressFromArray( $address, $value ); |
|
290 | - $this->basket->setAddress( $address, $type ); |
|
289 | + $this->setAddressFromArray($address, $value); |
|
290 | + $this->basket->setAddress($address, $type); |
|
291 | 291 | } |
292 | - else if( $value === null ) |
|
292 | + else if ($value === null) |
|
293 | 293 | { |
294 | - $this->basket->deleteAddress( $type ); |
|
294 | + $this->basket->deleteAddress($type); |
|
295 | 295 | } |
296 | 296 | else |
297 | 297 | { |
298 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
298 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
299 | 299 | } |
300 | 300 | |
301 | - $this->domainManager->setSession( $this->basket ); |
|
301 | + $this->domainManager->setSession($this->basket); |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -311,43 +311,43 @@ discard block |
||
311 | 311 | * entered by the customer when choosing one of the delivery or payment options |
312 | 312 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
313 | 313 | */ |
314 | - public function setService( $type, $id, array $attributes = array() ) |
|
314 | + public function setService($type, $id, array $attributes = array()) |
|
315 | 315 | { |
316 | 316 | $context = $this->getContext(); |
317 | 317 | |
318 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
319 | - $serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) ); |
|
318 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
319 | + $serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text')); |
|
320 | 320 | |
321 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
322 | - $result = $provider->checkConfigFE( $attributes ); |
|
323 | - $unknown = array_diff_key( $attributes, $result ); |
|
321 | + $provider = $serviceManager->getProvider($serviceItem); |
|
322 | + $result = $provider->checkConfigFE($attributes); |
|
323 | + $unknown = array_diff_key($attributes, $result); |
|
324 | 324 | |
325 | - if( count( $unknown ) > 0 ) |
|
325 | + if (count($unknown) > 0) |
|
326 | 326 | { |
327 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
328 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
327 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
328 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
329 | 329 | } |
330 | 330 | |
331 | - foreach( $result as $key => $value ) |
|
331 | + foreach ($result as $key => $value) |
|
332 | 332 | { |
333 | - if( $value !== null ) { |
|
334 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
333 | + if ($value !== null) { |
|
334 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 | |
338 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
338 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
339 | 339 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
340 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
340 | + $orderServiceItem->copyFrom($serviceItem); |
|
341 | 341 | |
342 | - $price = $provider->calcPrice( $this->basket ); |
|
342 | + $price = $provider->calcPrice($this->basket); |
|
343 | 343 | // remove service rebate of original price |
344 | - $price->setRebate( '0.00' ); |
|
345 | - $orderServiceItem->setPrice( $price ); |
|
344 | + $price->setRebate('0.00'); |
|
345 | + $orderServiceItem->setPrice($price); |
|
346 | 346 | |
347 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
347 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
348 | 348 | |
349 | - $this->basket->setService( $orderServiceItem, $type ); |
|
350 | - $this->domainManager->setSession( $this->basket ); |
|
349 | + $this->basket->setService($orderServiceItem, $type); |
|
350 | + $this->domainManager->setSession($this->basket); |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | |
@@ -359,44 +359,44 @@ discard block |
||
359 | 359 | * @param array $variantAttributeIds List of product variant attribute IDs |
360 | 360 | * @param string $warehouse |
361 | 361 | */ |
362 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
363 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $warehouse ) |
|
362 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
363 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $warehouse) |
|
364 | 364 | { |
365 | 365 | $quantity = $orderBaseProductItem->getQuantity(); |
366 | 366 | $products = $subProductIds = $orderProducts = array(); |
367 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
367 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
368 | 368 | |
369 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
369 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
370 | 370 | $subProductIds[] = $item->getId(); |
371 | 371 | } |
372 | 372 | |
373 | - if( count( $subProductIds ) > 0 ) |
|
373 | + if (count($subProductIds) > 0) |
|
374 | 374 | { |
375 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
375 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
376 | 376 | |
377 | - $search = $productManager->createSearch( true ); |
|
377 | + $search = $productManager->createSearch(true); |
|
378 | 378 | $expr = array( |
379 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
379 | + $search->compare('==', 'product.id', $subProductIds), |
|
380 | 380 | $search->getConditions(), |
381 | 381 | ); |
382 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
382 | + $search->setConditions($search->combine('&&', $expr)); |
|
383 | 383 | |
384 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
384 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
385 | 385 | } |
386 | 386 | |
387 | - foreach( $products as $product ) |
|
387 | + foreach ($products as $product) |
|
388 | 388 | { |
389 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
389 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
390 | 390 | |
391 | 391 | $orderProduct = $orderProductManager->createItem(); |
392 | - $orderProduct->copyFrom( $product ); |
|
393 | - $orderProduct->setWarehouseCode( $warehouse ); |
|
394 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
392 | + $orderProduct->copyFrom($product); |
|
393 | + $orderProduct->setWarehouseCode($warehouse); |
|
394 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
395 | 395 | |
396 | 396 | $orderProducts[] = $orderProduct; |
397 | 397 | } |
398 | 398 | |
399 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
399 | + $orderBaseProductItem->setProducts($orderProducts); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | |
@@ -410,34 +410,34 @@ discard block |
||
410 | 410 | $session = $context->getSession(); |
411 | 411 | $locale = $this->basket->getLocale(); |
412 | 412 | |
413 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
413 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
414 | 414 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
415 | 415 | |
416 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
416 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
417 | 417 | { |
418 | - $locParts = explode( '|', $localeStr ); |
|
419 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
420 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
421 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
418 | + $locParts = explode('|', $localeStr); |
|
419 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
420 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
421 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
422 | 422 | |
423 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
424 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
423 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
424 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
425 | 425 | |
426 | 426 | $context = clone $context; |
427 | - $context->setLocale( $locale ); |
|
427 | + $context->setLocale($locale); |
|
428 | 428 | |
429 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
429 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
430 | 430 | $basket = $manager->getSession(); |
431 | 431 | |
432 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
433 | - $this->copyServices( $basket, $errors ); |
|
434 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
435 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
432 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
433 | + $this->copyServices($basket, $errors); |
|
434 | + $this->copyProducts($basket, $errors, $localeKey); |
|
435 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
436 | 436 | |
437 | - $manager->setSession( $basket ); |
|
437 | + $manager->setSession($basket); |
|
438 | 438 | } |
439 | 439 | |
440 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
440 | + $session->set('aimeos/basket/locale', $localeKey); |
|
441 | 441 | } |
442 | 442 | |
443 | 443 | |
@@ -449,20 +449,20 @@ discard block |
||
449 | 449 | * @param string $localeKey Unique identifier of the site, language and currency |
450 | 450 | * @return array Associative list of errors occured |
451 | 451 | */ |
452 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
452 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
453 | 453 | { |
454 | - foreach( $basket->getAddresses() as $type => $item ) |
|
454 | + foreach ($basket->getAddresses() as $type => $item) |
|
455 | 455 | { |
456 | 456 | try |
457 | 457 | { |
458 | - $this->setAddress( $type, $item->toArray() ); |
|
459 | - $basket->deleteAddress( $type ); |
|
458 | + $this->setAddress($type, $item->toArray()); |
|
459 | + $basket->deleteAddress($type); |
|
460 | 460 | } |
461 | - catch( \Exception $e ) |
|
461 | + catch (\Exception $e) |
|
462 | 462 | { |
463 | 463 | $logger = $this->getContext()->getLogger(); |
464 | 464 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
465 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
465 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
466 | 466 | $errors['address'][$type] = $e->getMessage(); |
467 | 467 | } |
468 | 468 | } |
@@ -479,20 +479,20 @@ discard block |
||
479 | 479 | * @param string $localeKey Unique identifier of the site, language and currency |
480 | 480 | * @return array Associative list of errors occured |
481 | 481 | */ |
482 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
482 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
483 | 483 | { |
484 | - foreach( $basket->getCoupons() as $code => $list ) |
|
484 | + foreach ($basket->getCoupons() as $code => $list) |
|
485 | 485 | { |
486 | 486 | try |
487 | 487 | { |
488 | - $this->addCoupon( $code ); |
|
489 | - $basket->deleteCoupon( $code, true ); |
|
488 | + $this->addCoupon($code); |
|
489 | + $basket->deleteCoupon($code, true); |
|
490 | 490 | } |
491 | - catch( \Exception $e ) |
|
491 | + catch (\Exception $e) |
|
492 | 492 | { |
493 | 493 | $logger = $this->getContext()->getLogger(); |
494 | 494 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
495 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
495 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
496 | 496 | $errors['coupon'][$code] = $e->getMessage(); |
497 | 497 | } |
498 | 498 | } |
@@ -509,11 +509,11 @@ discard block |
||
509 | 509 | * @param string $localeKey Unique identifier of the site, language and currency |
510 | 510 | * @return array Associative list of errors occured |
511 | 511 | */ |
512 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
512 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
513 | 513 | { |
514 | - foreach( $basket->getProducts() as $pos => $product ) |
|
514 | + foreach ($basket->getProducts() as $pos => $product) |
|
515 | 515 | { |
516 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
516 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
517 | 517 | continue; |
518 | 518 | } |
519 | 519 | |
@@ -521,7 +521,7 @@ discard block |
||
521 | 521 | { |
522 | 522 | $attrIds = array(); |
523 | 523 | |
524 | - foreach( $product->getAttributes() as $attrItem ) { |
|
524 | + foreach ($product->getAttributes() as $attrItem) { |
|
525 | 525 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
526 | 526 | } |
527 | 527 | |
@@ -529,21 +529,21 @@ discard block |
||
529 | 529 | $product->getProductId(), |
530 | 530 | $product->getQuantity(), |
531 | 531 | array(), |
532 | - $this->getValue( $attrIds, 'variant', array() ), |
|
533 | - $this->getValue( $attrIds, 'config', array() ), |
|
534 | - $this->getValue( $attrIds, 'hidden', array() ), |
|
535 | - $this->getValue( $attrIds, 'custom', array() ), |
|
532 | + $this->getValue($attrIds, 'variant', array()), |
|
533 | + $this->getValue($attrIds, 'config', array()), |
|
534 | + $this->getValue($attrIds, 'hidden', array()), |
|
535 | + $this->getValue($attrIds, 'custom', array()), |
|
536 | 536 | $product->getWarehouseCode() |
537 | 537 | ); |
538 | 538 | |
539 | - $basket->deleteProduct( $pos ); |
|
539 | + $basket->deleteProduct($pos); |
|
540 | 540 | } |
541 | - catch( \Exception $e ) |
|
541 | + catch (\Exception $e) |
|
542 | 542 | { |
543 | 543 | $code = $product->getProductCode(); |
544 | 544 | $logger = $this->getContext()->getLogger(); |
545 | 545 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
546 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
546 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
547 | 547 | $errors['product'][$pos] = $e->getMessage(); |
548 | 548 | } |
549 | 549 | } |
@@ -559,22 +559,22 @@ discard block |
||
559 | 559 | * @param array $errors Associative list of previous errors |
560 | 560 | * @return array Associative list of errors occured |
561 | 561 | */ |
562 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
562 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
563 | 563 | { |
564 | - foreach( $basket->getServices() as $type => $item ) |
|
564 | + foreach ($basket->getServices() as $type => $item) |
|
565 | 565 | { |
566 | 566 | try |
567 | 567 | { |
568 | 568 | $attributes = array(); |
569 | 569 | |
570 | - foreach( $item->getAttributes() as $attrItem ) { |
|
570 | + foreach ($item->getAttributes() as $attrItem) { |
|
571 | 571 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
572 | 572 | } |
573 | 573 | |
574 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
575 | - $basket->deleteService( $type ); |
|
574 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
575 | + $basket->deleteService($type); |
|
576 | 576 | } |
577 | - catch( \Exception $e ) {; } // Don't notify the user as appropriate services can be added automatically |
|
577 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
578 | 578 | } |
579 | 579 | |
580 | 580 | return $errors; |
@@ -589,18 +589,18 @@ discard block |
||
589 | 589 | * an address item. |
590 | 590 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
591 | 591 | */ |
592 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
592 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
593 | 593 | { |
594 | - foreach( $map as $key => $value ) { |
|
595 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
594 | + foreach ($map as $key => $value) { |
|
595 | + $map[$key] = strip_tags($value); // prevent XSS |
|
596 | 596 | } |
597 | 597 | |
598 | - $errors = $address->fromArray( $map ); |
|
598 | + $errors = $address->fromArray($map); |
|
599 | 599 | |
600 | - if( count( $errors ) > 0 ) |
|
600 | + if (count($errors) > 0) |
|
601 | 601 | { |
602 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
603 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
602 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
603 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
604 | 604 | } |
605 | 605 | } |
606 | 606 | |
@@ -616,44 +616,44 @@ discard block |
||
616 | 616 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
617 | 617 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
618 | 618 | */ |
619 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
620 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
619 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
620 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
621 | 621 | { |
622 | 622 | $attr = array(); |
623 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
623 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
624 | 624 | |
625 | - if( count( $productItems ) > 1 ) |
|
625 | + if (count($productItems) > 1) |
|
626 | 626 | { |
627 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
628 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
627 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
628 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
629 | 629 | } |
630 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
630 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
631 | 631 | { |
632 | 632 | $productItem = $result; |
633 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
633 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
634 | 634 | |
635 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
635 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
636 | 636 | |
637 | - if( count( $subprices ) > 0 ) { |
|
637 | + if (count($subprices) > 0) { |
|
638 | 638 | $prices = $subprices; |
639 | 639 | } |
640 | 640 | |
641 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
642 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
641 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
642 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
643 | 643 | |
644 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
644 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
645 | 645 | { |
646 | 646 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
647 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
648 | - $orderAttributeItem->setType( 'variant' ); |
|
647 | + $orderAttributeItem->copyFrom($attrItem); |
|
648 | + $orderAttributeItem->setType('variant'); |
|
649 | 649 | |
650 | 650 | $attr[] = $orderAttributeItem; |
651 | 651 | } |
652 | 652 | } |
653 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
653 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
654 | 654 | { |
655 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
656 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
655 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
656 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
657 | 657 | } |
658 | 658 | |
659 | 659 | return $attr; |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
57 | 57 | * @return void |
58 | 58 | */ |
59 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
59 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
60 | 60 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
61 | - $warehouse = 'default' ); |
|
61 | + $warehouse = 'default'); |
|
62 | 62 | |
63 | 63 | |
64 | 64 | /** |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | * @param integer $position Position number (key) of the order product item |
68 | 68 | * @return void |
69 | 69 | */ |
70 | - public function deleteProduct( $position ); |
|
70 | + public function deleteProduct($position); |
|
71 | 71 | |
72 | 72 | |
73 | 73 | /** |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | * @param array $configAttributeCodes Codes of the product config attributes that should be REMOVED |
79 | 79 | * @return void |
80 | 80 | */ |
81 | - public function editProduct( $position, $quantity, array $configAttributeCodes = array() ); |
|
81 | + public function editProduct($position, $quantity, array $configAttributeCodes = array()); |
|
82 | 82 | |
83 | 83 | |
84 | 84 | /** |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
89 | 89 | * @return void |
90 | 90 | */ |
91 | - public function addCoupon( $code ); |
|
91 | + public function addCoupon($code); |
|
92 | 92 | |
93 | 93 | |
94 | 94 | /** |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
99 | 99 | * @return void |
100 | 100 | */ |
101 | - public function deleteCoupon( $code ); |
|
101 | + public function deleteCoupon($code); |
|
102 | 102 | |
103 | 103 | |
104 | 104 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * if one of the keys is invalid when using an array with key/value pairs |
111 | 111 | * @return void |
112 | 112 | */ |
113 | - public function setAddress( $type, $value ); |
|
113 | + public function setAddress($type, $value); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | /** |
@@ -123,5 +123,5 @@ discard block |
||
123 | 123 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
124 | 124 | * @return void |
125 | 125 | */ |
126 | - public function setService( $type, $id, array $attributes = array() ); |
|
126 | + public function setService($type, $id, array $attributes = array()); |
|
127 | 127 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|null $name Name of the controller implementaton (default: "Standard") |
30 | 30 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
31 | 31 | */ |
32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) |
|
32 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null) |
|
33 | 33 | { |
34 | 34 | /** controller/frontend/basket/name |
35 | 35 | * Class name of the used basket frontend controller implementation |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @since 2014.03 |
65 | 65 | * @category Developer |
66 | 66 | */ |
67 | - if( $name === null ) { |
|
68 | - $name = $context->getConfig()->get( 'controller/frontend/basket/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $context->getConfig()->get('controller/frontend/basket/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) |
|
71 | + if (ctype_alnum($name) === false) |
|
72 | 72 | { |
73 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Frontend\\Basket\\' . $name : '<not a string>'; |
|
74 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
73 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Frontend\\Basket\\' . $name : '<not a string>'; |
|
74 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $iface = '\\Aimeos\\Controller\\Frontend\\Basket\\Iface'; |
78 | 78 | $classname = '\\Aimeos\\Controller\\Frontend\\Basket\\' . $name; |
79 | 79 | |
80 | - $manager = self::createControllerBase( $context, $classname, $iface ); |
|
80 | + $manager = self::createControllerBase($context, $classname, $iface); |
|
81 | 81 | |
82 | 82 | /** controller/frontend/basket/decorators/excludes |
83 | 83 | * Excludes decorators added by the "common" option from the basket frontend controllers |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @see controller/frontend/basket/decorators/excludes |
154 | 154 | * @see controller/frontend/basket/decorators/global |
155 | 155 | */ |
156 | - return self::addControllerDecorators( $context, $manager, 'basket' ); |
|
156 | + return self::addControllerDecorators($context, $manager, 'basket'); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | } |
@@ -29,9 +29,9 @@ discard block |
||
29 | 29 | * @return \Aimeos\MShop\Common\Manager\Iface Manager object |
30 | 30 | * @since 2015.08 |
31 | 31 | */ |
32 | - public function createManager( $name ) |
|
32 | + public function createManager($name) |
|
33 | 33 | { |
34 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), $name ); |
|
34 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), $name); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @return \Aimeos\MW\Criteria\Iface Criteria object for filtering |
43 | 43 | * @since 2015.08 |
44 | 44 | */ |
45 | - public function createCatalogFilter( $default = true ) |
|
45 | + public function createCatalogFilter($default = true) |
|
46 | 46 | { |
47 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' )->createSearch( $default ); |
|
47 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog')->createSearch($default); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | |
@@ -56,9 +56,9 @@ discard block |
||
56 | 56 | * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys |
57 | 57 | * @since 2015.08 |
58 | 58 | */ |
59 | - public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) ) |
|
59 | + public function getCatalogPath($id, array $domains = array('text', 'media')) |
|
60 | 60 | { |
61 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' )->getPath( $id, $domains ); |
|
61 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog')->getPath($id, $domains); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | |
@@ -73,10 +73,10 @@ discard block |
||
73 | 73 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant |
74 | 74 | * @since 2015.08 |
75 | 75 | */ |
76 | - public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ), |
|
77 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null ) |
|
76 | + public function getCatalogTree($id = null, array $domains = array('text', 'media'), |
|
77 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null) |
|
78 | 78 | { |
79 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog' )->getTree( $id, $domains, $level, $search ); |
|
79 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog')->getTree($id, $domains, $level, $search); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * @return array Associative list of key values as key and the product count for this key as value |
89 | 89 | * @since 2015.08 |
90 | 90 | */ |
91 | - public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key ) |
|
91 | + public function aggregateIndex(\Aimeos\MW\Criteria\Iface $filter, $key) |
|
92 | 92 | { |
93 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->aggregate( $filter, $key ); |
|
93 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->aggregate($filter, $key); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | |
@@ -105,46 +105,46 @@ discard block |
||
105 | 105 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
106 | 106 | * @since 2015.08 |
107 | 107 | */ |
108 | - public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
108 | + public function createIndexFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
109 | 109 | { |
110 | 110 | $sortations = array(); |
111 | 111 | $context = $this->getContext(); |
112 | 112 | |
113 | - $search = \Aimeos\MShop\Factory::createManager( $context, 'index' )->createSearch( true ); |
|
114 | - $expr = array( $search->compare( '!=', 'index.catalog.id', null ) ); |
|
113 | + $search = \Aimeos\MShop\Factory::createManager($context, 'index')->createSearch(true); |
|
114 | + $expr = array($search->compare('!=', 'index.catalog.id', null)); |
|
115 | 115 | |
116 | - switch( $sort ) |
|
116 | + switch ($sort) |
|
117 | 117 | { |
118 | 118 | case 'code': |
119 | - $sortations[] = $search->sort( $direction, 'product.code' ); |
|
119 | + $sortations[] = $search->sort($direction, 'product.code'); |
|
120 | 120 | break; |
121 | 121 | |
122 | 122 | case 'name': |
123 | 123 | $langid = $context->getLocale()->getLanguageId(); |
124 | 124 | |
125 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
126 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
125 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
126 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
127 | 127 | |
128 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
129 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
128 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
129 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
130 | 130 | break; |
131 | 131 | |
132 | 132 | case 'price': |
133 | 133 | $currencyid = $context->getLocale()->getCurrencyId(); |
134 | 134 | |
135 | - $cmpfunc = $search->createFunction( 'index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
136 | - $expr[] = $search->compare( '>=', $cmpfunc, '0.00' ); |
|
135 | + $cmpfunc = $search->createFunction('index.price.value', array($listtype, $currencyid, 'default')); |
|
136 | + $expr[] = $search->compare('>=', $cmpfunc, '0.00'); |
|
137 | 137 | |
138 | - $sortfunc = $search->createFunction( 'sort:index.price.value', array( $listtype, $currencyid, 'default' ) ); |
|
139 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
138 | + $sortfunc = $search->createFunction('sort:index.price.value', array($listtype, $currencyid, 'default')); |
|
139 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
140 | 140 | break; |
141 | 141 | } |
142 | 142 | |
143 | 143 | $expr[] = $search->getConditions(); |
144 | 144 | |
145 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
146 | - $search->setSortations( $sortations ); |
|
147 | - $search->setSlice( $start, $size ); |
|
145 | + $search->setConditions($search->combine('&&', $expr)); |
|
146 | + $search->setSortations($sortations); |
|
147 | + $search->setSlice($start, $size); |
|
148 | 148 | |
149 | 149 | return $search; |
150 | 150 | } |
@@ -162,22 +162,22 @@ discard block |
||
162 | 162 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
163 | 163 | * @since 2015.08 |
164 | 164 | */ |
165 | - public function createIndexFilterCategory( $catid, $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
165 | + public function createIndexFilterCategory($catid, $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
166 | 166 | { |
167 | - $search = $this->createIndexFilter( $sort, $direction, $start, $size, $listtype ); |
|
168 | - $expr = array( $search->compare( '==', 'index.catalog.id', $catid ) ); |
|
167 | + $search = $this->createIndexFilter($sort, $direction, $start, $size, $listtype); |
|
168 | + $expr = array($search->compare('==', 'index.catalog.id', $catid)); |
|
169 | 169 | |
170 | - if( $sort === 'relevance' ) |
|
170 | + if ($sort === 'relevance') |
|
171 | 171 | { |
172 | - $cmpfunc = $search->createFunction( 'index.catalog.position', array( $listtype, $catid ) ); |
|
173 | - $expr[] = $search->compare( '>=', $cmpfunc, 0 ); |
|
172 | + $cmpfunc = $search->createFunction('index.catalog.position', array($listtype, $catid)); |
|
173 | + $expr[] = $search->compare('>=', $cmpfunc, 0); |
|
174 | 174 | |
175 | - $sortfunc = $search->createFunction( 'sort:index.catalog.position', array( $listtype, $catid ) ); |
|
176 | - $search->setSortations( array( $search->sort( $direction, $sortfunc ) ) ); |
|
175 | + $sortfunc = $search->createFunction('sort:index.catalog.position', array($listtype, $catid)); |
|
176 | + $search->setSortations(array($search->sort($direction, $sortfunc))); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | $expr[] = $search->getConditions(); |
180 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
180 | + $search->setConditions($search->combine('&&', $expr)); |
|
181 | 181 | |
182 | 182 | return $search; |
183 | 183 | } |
@@ -195,16 +195,16 @@ discard block |
||
195 | 195 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
196 | 196 | * @since 2015.08 |
197 | 197 | */ |
198 | - public function createIndexFilterText( $input, $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ) |
|
198 | + public function createIndexFilterText($input, $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default') |
|
199 | 199 | { |
200 | 200 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
201 | - $search = $this->createIndexFilter( $sort, $direction, $start, $size, $listtype ); |
|
202 | - $expr = array( $search->compare( '>', $search->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ), 0 ) ); |
|
201 | + $search = $this->createIndexFilter($sort, $direction, $start, $size, $listtype); |
|
202 | + $expr = array($search->compare('>', $search->createFunction('index.text.relevance', array($listtype, $langid, $input)), 0)); |
|
203 | 203 | |
204 | 204 | // we don't need to sort by 'sort:index.text.relevance' because it's a boolean match (relevance is either 0 or 1) |
205 | 205 | |
206 | 206 | $expr[] = $search->getConditions(); |
207 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
207 | + $search->setConditions($search->combine('&&', $expr)); |
|
208 | 208 | |
209 | 209 | return $search; |
210 | 210 | } |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
219 | 219 | * @since 2015.08 |
220 | 220 | */ |
221 | - public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid ) |
|
221 | + public function addIndexFilterCategory(\Aimeos\MW\Criteria\Iface $search, $catid) |
|
222 | 222 | { |
223 | - $expr = array( $search->compare( '==', 'index.catalog.id', $catid ) ); |
|
223 | + $expr = array($search->compare('==', 'index.catalog.id', $catid)); |
|
224 | 224 | |
225 | 225 | $expr[] = $search->getConditions(); |
226 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
226 | + $search->setConditions($search->combine('&&', $expr)); |
|
227 | 227 | |
228 | 228 | return $search; |
229 | 229 | } |
@@ -238,13 +238,13 @@ discard block |
||
238 | 238 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
239 | 239 | * @since 2015.08 |
240 | 240 | */ |
241 | - public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' ) |
|
241 | + public function addIndexFilterText(\Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default') |
|
242 | 242 | { |
243 | 243 | $langid = $this->getContext()->getLocale()->getLanguageId(); |
244 | - $expr = array( $search->compare( '>', $search->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ), 0 ) ); |
|
244 | + $expr = array($search->compare('>', $search->createFunction('index.text.relevance', array($listtype, $langid, $input)), 0)); |
|
245 | 245 | |
246 | 246 | $expr[] = $search->getConditions(); |
247 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
247 | + $search->setConditions($search->combine('&&', $expr)); |
|
248 | 248 | |
249 | 249 | return $search; |
250 | 250 | } |
@@ -259,9 +259,9 @@ discard block |
||
259 | 259 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
260 | 260 | * @since 2015.08 |
261 | 261 | */ |
262 | - public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ) |
|
262 | + public function getIndexItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null) |
|
263 | 263 | { |
264 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index' )->searchItems( $filter, $domains, $total ); |
|
264 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index')->searchItems($filter, $domains, $total); |
|
265 | 265 | } |
266 | 266 | |
267 | 267 | |
@@ -274,19 +274,19 @@ discard block |
||
274 | 274 | * @throws \Aimeos\Controller\Frontend\Catalog\Exception If product isn't available |
275 | 275 | * @since 2015.08 |
276 | 276 | */ |
277 | - public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ) |
|
277 | + public function getProductItems(array $ids, array $domains = array('media', 'price', 'text')) |
|
278 | 278 | { |
279 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
279 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
280 | 280 | |
281 | - $search = $manager->createSearch( true ); |
|
281 | + $search = $manager->createSearch(true); |
|
282 | 282 | $expr = array( |
283 | - $search->compare( '==', 'product.id', $ids ), |
|
283 | + $search->compare('==', 'product.id', $ids), |
|
284 | 284 | $search->getConditions(), |
285 | 285 | ); |
286 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
287 | - $search->setSlice( 0, count( $ids ) ); |
|
286 | + $search->setConditions($search->combine('&&', $expr)); |
|
287 | + $search->setSlice(0, count($ids)); |
|
288 | 288 | |
289 | - return $manager->searchItems( $search, $domains ); |
|
289 | + return $manager->searchItems($search, $domains); |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | |
@@ -302,37 +302,37 @@ discard block |
||
302 | 302 | * @param string $type Type of the text like "name", "short", "long", etc. |
303 | 303 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
304 | 304 | */ |
305 | - public function createTextFilter( $input, $sort = null, $direction = '+', $start = 0, $size = 25, $listtype = 'default', $type = 'name' ) |
|
305 | + public function createTextFilter($input, $sort = null, $direction = '+', $start = 0, $size = 25, $listtype = 'default', $type = 'name') |
|
306 | 306 | { |
307 | 307 | $locale = $this->getContext()->getLocale(); |
308 | 308 | $langid = $locale->getLanguageId(); |
309 | 309 | |
310 | - $search = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index/text' )->createSearch( true ); |
|
310 | + $search = \Aimeos\MShop\Factory::createManager($this->getContext(), 'index/text')->createSearch(true); |
|
311 | 311 | |
312 | 312 | $expr = array( |
313 | - $search->compare( '>', $search->createFunction( 'index.text.relevance', array( $listtype, $langid, $input ) ), 0 ), |
|
314 | - $search->compare( '>', $search->createFunction( 'index.text.value', array( $listtype, $langid, $type, 'product' ) ), '' ), |
|
313 | + $search->compare('>', $search->createFunction('index.text.relevance', array($listtype, $langid, $input)), 0), |
|
314 | + $search->compare('>', $search->createFunction('index.text.value', array($listtype, $langid, $type, 'product')), ''), |
|
315 | 315 | ); |
316 | 316 | |
317 | 317 | $sortations = array(); |
318 | 318 | |
319 | - switch( $sort ) |
|
319 | + switch ($sort) |
|
320 | 320 | { |
321 | 321 | case 'name': |
322 | - $cmpfunc = $search->createFunction( 'index.text.value', array( $listtype, $langid, 'name', 'product' ) ); |
|
323 | - $expr[] = $search->compare( '>=', $cmpfunc, '' ); |
|
322 | + $cmpfunc = $search->createFunction('index.text.value', array($listtype, $langid, 'name', 'product')); |
|
323 | + $expr[] = $search->compare('>=', $cmpfunc, ''); |
|
324 | 324 | |
325 | - $sortfunc = $search->createFunction( 'sort:index.text.value', array( $listtype, $langid, 'name' ) ); |
|
326 | - $sortations[] = $search->sort( $direction, $sortfunc ); |
|
325 | + $sortfunc = $search->createFunction('sort:index.text.value', array($listtype, $langid, 'name')); |
|
326 | + $sortations[] = $search->sort($direction, $sortfunc); |
|
327 | 327 | break; |
328 | 328 | |
329 | 329 | case 'relevance': |
330 | 330 | // we don't need to sort by 'sort:index.text.relevance' because it's a boolean match (relevance is either 0 or 1) |
331 | 331 | } |
332 | 332 | |
333 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
334 | - $search->setSortations( $sortations ); |
|
335 | - $search->setSlice( $start, $size ); |
|
333 | + $search->setConditions($search->combine('&&', $expr)); |
|
334 | + $search->setSortations($sortations); |
|
335 | + $search->setSlice($start, $size); |
|
336 | 336 | |
337 | 337 | return $search; |
338 | 338 | } |
@@ -344,8 +344,8 @@ discard block |
||
344 | 344 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
345 | 345 | * @return array Associative list of the product ID as key and the product text as value |
346 | 346 | */ |
347 | - public function getTextList( \Aimeos\MW\Criteria\Iface $filter ) |
|
347 | + public function getTextList(\Aimeos\MW\Criteria\Iface $filter) |
|
348 | 348 | { |
349 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'index/text' )->searchTexts( $filter ); |
|
349 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'index/text')->searchTexts($filter); |
|
350 | 350 | } |
351 | 351 | } |
@@ -256,6 +256,7 @@ |
||
256 | 256 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
257 | 257 | * @param string[] $domains Domain names of items that are associated with the products and that should be fetched too |
258 | 258 | * @param integer &$total Parameter where the total number of found products will be stored in |
259 | + * @param integer $total |
|
259 | 260 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
260 | 261 | * @since 2015.08 |
261 | 262 | */ |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | * @param string $name Name of the manager |
28 | 28 | * @return \Aimeos\MShop\Common\Manager\Iface Manager object |
29 | 29 | */ |
30 | - public function createManager( $name ); |
|
30 | + public function createManager($name); |
|
31 | 31 | |
32 | 32 | |
33 | 33 | /** |
@@ -47,7 +47,7 @@ discard block |
||
47 | 47 | * @return array Associative list of items implementing \Aimeos\MShop\Catalog\Item\Iface with their IDs as keys |
48 | 48 | * @since 2015.08 |
49 | 49 | */ |
50 | - public function getCatalogPath( $id, array $domains = array( 'text', 'media' ) ); |
|
50 | + public function getCatalogPath($id, array $domains = array('text', 'media')); |
|
51 | 51 | |
52 | 52 | |
53 | 53 | /** |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @return \Aimeos\MShop\Catalog\Item\Iface Catalog node, maybe with children depending on the level constant |
62 | 62 | * @since 2015.08 |
63 | 63 | */ |
64 | - public function getCatalogTree( $id = null, array $domains = array( 'text', 'media' ), |
|
65 | - $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null ); |
|
64 | + public function getCatalogTree($id = null, array $domains = array('text', 'media'), |
|
65 | + $level = \Aimeos\MW\Tree\Manager\Base::LEVEL_TREE, \Aimeos\MW\Criteria\Iface $search = null); |
|
66 | 66 | |
67 | 67 | |
68 | 68 | /** |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | * @return array Associative list of key values as key and the product count for this key as value |
74 | 74 | * @since 2015.08 |
75 | 75 | */ |
76 | - public function aggregateIndex( \Aimeos\MW\Criteria\Iface $filter, $key ); |
|
76 | + public function aggregateIndex(\Aimeos\MW\Criteria\Iface $filter, $key); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | /** |
@@ -84,7 +84,7 @@ discard block |
||
84 | 84 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
85 | 85 | * @since 2015.08 |
86 | 86 | */ |
87 | - public function addIndexFilterCategory( \Aimeos\MW\Criteria\Iface $search, $catid ); |
|
87 | + public function addIndexFilterCategory(\Aimeos\MW\Criteria\Iface $search, $catid); |
|
88 | 88 | |
89 | 89 | |
90 | 90 | /** |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
97 | 97 | * @since 2015.08 |
98 | 98 | */ |
99 | - public function addIndexFilterText( \Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default' ); |
|
99 | + public function addIndexFilterText(\Aimeos\MW\Criteria\Iface $search, $input, $listtype = 'default'); |
|
100 | 100 | |
101 | 101 | |
102 | 102 | /** |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
111 | 111 | * @since 2015.08 |
112 | 112 | */ |
113 | - public function createIndexFilter( $sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default' ); |
|
113 | + public function createIndexFilter($sort = null, $direction = '+', $start = 0, $size = 100, $listtype = 'default'); |
|
114 | 114 | |
115 | 115 | |
116 | 116 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
126 | 126 | * @since 2015.08 |
127 | 127 | */ |
128 | - public function createIndexFilterCategory( $catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' ); |
|
128 | + public function createIndexFilterCategory($catid, $sort = 'position', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default'); |
|
129 | 129 | |
130 | 130 | |
131 | 131 | /** |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
141 | 141 | * @since 2015.08 |
142 | 142 | */ |
143 | - public function createIndexFilterText( $input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default' ); |
|
143 | + public function createIndexFilterText($input, $sort = 'relevance', $direction = 'asc', $start = 0, $size = 100, $listtype = 'default'); |
|
144 | 144 | |
145 | 145 | |
146 | 146 | /** |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | * @return array Ordered list of product items implementing \Aimeos\MShop\Product\Item\Iface |
153 | 153 | * @since 2015.08 |
154 | 154 | */ |
155 | - public function getIndexItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = array( 'media', 'price', 'text' ), &$total = null ); |
|
155 | + public function getIndexItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = array('media', 'price', 'text'), &$total = null); |
|
156 | 156 | |
157 | 157 | |
158 | 158 | /** |
@@ -163,7 +163,7 @@ discard block |
||
163 | 163 | * @return array List of product items implementing \Aimeos\MShop\Product\Item\Iface |
164 | 164 | * @since 2015.08 |
165 | 165 | */ |
166 | - public function getProductItems( array $ids, array $domains = array( 'media', 'price', 'text' ) ); |
|
166 | + public function getProductItems(array $ids, array $domains = array('media', 'price', 'text')); |
|
167 | 167 | |
168 | 168 | |
169 | 169 | /** |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param string $type Type of the text like "name", "short", "long", etc. |
179 | 179 | * @return \Aimeos\MW\Criteria\Iface Criteria object containing the conditions for searching |
180 | 180 | */ |
181 | - public function createTextFilter( $input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name' ); |
|
181 | + public function createTextFilter($input, $sort = null, $direction = 'desc', $start = 0, $size = 25, $listtype = 'default', $type = 'name'); |
|
182 | 182 | |
183 | 183 | |
184 | 184 | /** |
@@ -187,5 +187,5 @@ discard block |
||
187 | 187 | * @param \Aimeos\MW\Criteria\Iface $filter Critera object which contains the filter conditions |
188 | 188 | * @return array Associative list of the product ID as key and the product text as value |
189 | 189 | */ |
190 | - public function getTextList( \Aimeos\MW\Criteria\Iface $filter ); |
|
190 | + public function getTextList(\Aimeos\MW\Criteria\Iface $filter); |
|
191 | 191 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | * @param string|null $name Name of the controller implementaton (default: "Standard") |
30 | 30 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
31 | 31 | */ |
32 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null ) |
|
32 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null) |
|
33 | 33 | { |
34 | 34 | /** controller/frontend/catalog/name |
35 | 35 | * Class name of the used catalog frontend controller implementation |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | * @since 2014.03 |
65 | 65 | * @category Developer |
66 | 66 | */ |
67 | - if( $name === null ) { |
|
68 | - $name = $context->getConfig()->get( 'controller/frontend/catalog/name', 'Standard' ); |
|
67 | + if ($name === null) { |
|
68 | + $name = $context->getConfig()->get('controller/frontend/catalog/name', 'Standard'); |
|
69 | 69 | } |
70 | 70 | |
71 | - if( ctype_alnum( $name ) === false ) |
|
71 | + if (ctype_alnum($name) === false) |
|
72 | 72 | { |
73 | - $classname = is_string( $name ) ? '\\Aimeos\\Controller\\Frontend\\Catalog\\' . $name : '<not a string>'; |
|
74 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
73 | + $classname = is_string($name) ? '\\Aimeos\\Controller\\Frontend\\Catalog\\' . $name : '<not a string>'; |
|
74 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $iface = '\\Aimeos\\Controller\\Frontend\\Catalog\\Iface'; |
78 | 78 | $classname = '\\Aimeos\\Controller\\Frontend\\Catalog\\' . $name; |
79 | 79 | |
80 | - $manager = self::createControllerBase( $context, $classname, $iface ); |
|
80 | + $manager = self::createControllerBase($context, $classname, $iface); |
|
81 | 81 | |
82 | 82 | /** controller/frontend/catalog/decorators/excludes |
83 | 83 | * Excludes decorators added by the "common" option from the catalog frontend controllers |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | * @see controller/frontend/catalog/decorators/excludes |
154 | 154 | * @see controller/frontend/catalog/decorators/global |
155 | 155 | */ |
156 | - return self::addControllerDecorators( $context, $manager, 'catalog' ); |
|
156 | + return self::addControllerDecorators($context, $manager, 'catalog'); |
|
157 | 157 | } |
158 | 158 | |
159 | 159 | } |
@@ -32,22 +32,22 @@ discard block |
||
32 | 32 | * @param \Aimeos\MShop\Order\Item\Base\Iface $basket Basket object to be stored |
33 | 33 | * @return \Aimeos\MShop\Order\Item\Iface Order item that belongs to the stored basket |
34 | 34 | */ |
35 | - public function store( \Aimeos\MShop\Order\Item\Base\Iface $basket ) |
|
35 | + public function store(\Aimeos\MShop\Order\Item\Base\Iface $basket) |
|
36 | 36 | { |
37 | 37 | $context = $this->getContext(); |
38 | 38 | |
39 | - $orderManager = \Aimeos\MShop\Factory::createManager( $context, 'order' ); |
|
40 | - $orderBaseManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
39 | + $orderManager = \Aimeos\MShop\Factory::createManager($context, 'order'); |
|
40 | + $orderBaseManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
41 | 41 | |
42 | 42 | |
43 | 43 | $orderBaseManager->begin(); |
44 | - $orderBaseManager->store( $basket ); |
|
44 | + $orderBaseManager->store($basket); |
|
45 | 45 | $orderBaseManager->commit(); |
46 | 46 | |
47 | 47 | $orderItem = $orderManager->createItem(); |
48 | - $orderItem->setBaseId( $basket->getId() ); |
|
49 | - $orderItem->setType( \Aimeos\MShop\Order\Item\Base::TYPE_WEB ); |
|
50 | - $orderManager->saveItem( $orderItem ); |
|
48 | + $orderItem->setBaseId($basket->getId()); |
|
49 | + $orderItem->setType(\Aimeos\MShop\Order\Item\Base::TYPE_WEB); |
|
50 | + $orderManager->saveItem($orderItem); |
|
51 | 51 | |
52 | 52 | |
53 | 53 | return $orderItem; |
@@ -72,9 +72,9 @@ discard block |
||
72 | 72 | * |
73 | 73 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
74 | 74 | */ |
75 | - public function block( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
75 | + public function block(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
76 | 76 | { |
77 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->block( $orderItem ); |
|
77 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->block($orderItem); |
|
78 | 78 | } |
79 | 79 | |
80 | 80 | |
@@ -96,9 +96,9 @@ discard block |
||
96 | 96 | * |
97 | 97 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
98 | 98 | */ |
99 | - public function unblock( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
99 | + public function unblock(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
100 | 100 | { |
101 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->unblock( $orderItem ); |
|
101 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->unblock($orderItem); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * |
117 | 117 | * @param \Aimeos\MShop\Order\Item\Iface $orderItem Order item object |
118 | 118 | */ |
119 | - public function update( \Aimeos\MShop\Order\Item\Iface $orderItem ) |
|
119 | + public function update(\Aimeos\MShop\Order\Item\Iface $orderItem) |
|
120 | 120 | { |
121 | - \Aimeos\Controller\Common\Order\Factory::createController( $this->getContext() )->update( $orderItem ); |
|
121 | + \Aimeos\Controller\Common\Order\Factory::createController($this->getContext())->update($orderItem); |
|
122 | 122 | } |
123 | 123 | } |