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