@@ -27,5 +27,5 @@ |
||
27 | 27 | * @param string|null $name Name of the controller implementation (Default if null) |
28 | 28 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
29 | 29 | */ |
30 | - public static function createController( \Aimeos\MShop\Context\Item\Iface $context, $name = null ); |
|
30 | + public static function createController(\Aimeos\MShop\Context\Item\Iface $context, $name = null); |
|
31 | 31 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $classname Full name of the class for which the object should be returned |
32 | 32 | * @param \Aimeos\Controller\Frontend\Iface|null $controller Frontend controller object |
33 | 33 | */ |
34 | - public static function injectController( $classname, \Aimeos\Controller\Frontend\Iface $controller = null ) |
|
34 | + public static function injectController($classname, \Aimeos\Controller\Frontend\Iface $controller = null) |
|
35 | 35 | { |
36 | 36 | self::$objects[$classname] = $controller; |
37 | 37 | } |
@@ -46,29 +46,29 @@ discard block |
||
46 | 46 | * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Controller\Frontend\Basket\Decorator\" |
47 | 47 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
48 | 48 | */ |
49 | - protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
50 | - \Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix ) |
|
49 | + protected static function addDecorators(\Aimeos\MShop\Context\Item\Iface $context, |
|
50 | + \Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix) |
|
51 | 51 | { |
52 | 52 | $iface = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\Iface'; |
53 | 53 | |
54 | - foreach( $decorators as $name ) |
|
54 | + foreach ($decorators as $name) |
|
55 | 55 | { |
56 | - if( ctype_alnum( $name ) === false ) |
|
56 | + if (ctype_alnum($name) === false) |
|
57 | 57 | { |
58 | - $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
59 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
58 | + $classname = is_string($name) ? $classprefix . $name : '<not a string>'; |
|
59 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $classname = $classprefix . $name; |
63 | 63 | |
64 | - if( class_exists( $classname ) === false ) { |
|
65 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
64 | + if (class_exists($classname) === false) { |
|
65 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname)); |
|
66 | 66 | } |
67 | 67 | |
68 | - $controller = new $classname( $controller, $context ); |
|
68 | + $controller = new $classname($controller, $context); |
|
69 | 69 | |
70 | - if( !( $controller instanceof $iface ) ) { |
|
71 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); |
|
70 | + if (!($controller instanceof $iface)) { |
|
71 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param string $domain Domain name in lower case, e.g. "product" |
85 | 85 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
86 | 86 | */ |
87 | - protected static function addControllerDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
88 | - \Aimeos\Controller\Frontend\Iface $controller, $domain ) |
|
87 | + protected static function addControllerDecorators(\Aimeos\MShop\Context\Item\Iface $context, |
|
88 | + \Aimeos\Controller\Frontend\Iface $controller, $domain) |
|
89 | 89 | { |
90 | - if( !is_string( $domain ) || $domain === '' ) { |
|
91 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid domain "%1$s"', $domain ) ); |
|
90 | + if (!is_string($domain) || $domain === '') { |
|
91 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid domain "%1$s"', $domain)); |
|
92 | 92 | } |
93 | 93 | |
94 | - $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $domain ) ) ); |
|
94 | + $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $domain))); |
|
95 | 95 | $config = $context->getConfig(); |
96 | 96 | |
97 | 97 | /** controller/frontend/common/decorators/default |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | * @since 2014.03 |
117 | 117 | * @category Developer |
118 | 118 | */ |
119 | - $decorators = $config->get( 'controller/frontend/common/decorators/default', array() ); |
|
120 | - $excludes = $config->get( 'controller/frontend/' . $domain . '/decorators/excludes', array() ); |
|
119 | + $decorators = $config->get('controller/frontend/common/decorators/default', array()); |
|
120 | + $excludes = $config->get('controller/frontend/' . $domain . '/decorators/excludes', array()); |
|
121 | 121 | |
122 | - foreach( $decorators as $key => $name ) |
|
122 | + foreach ($decorators as $key => $name) |
|
123 | 123 | { |
124 | - if( in_array( $name, $excludes ) ) { |
|
125 | - unset( $decorators[$key] ); |
|
124 | + if (in_array($name, $excludes)) { |
|
125 | + unset($decorators[$key]); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; |
130 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
130 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
131 | 131 | |
132 | 132 | $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; |
133 | - $decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/global', array() ); |
|
134 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
133 | + $decorators = $config->get('controller/frontend/' . $domain . '/decorators/global', array()); |
|
134 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
135 | 135 | |
136 | - $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $localClass ) . '\\Decorator\\'; |
|
137 | - $decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/local', array() ); |
|
138 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
136 | + $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst($localClass) . '\\Decorator\\'; |
|
137 | + $decorators = $config->get('controller/frontend/' . $domain . '/decorators/local', array()); |
|
138 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
139 | 139 | |
140 | 140 | return $controller; |
141 | 141 | } |
@@ -149,20 +149,20 @@ discard block |
||
149 | 149 | * @param string $interface Name of the controller interface |
150 | 150 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
151 | 151 | */ |
152 | - protected static function createControllerBase( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface ) |
|
152 | + protected static function createControllerBase(\Aimeos\MShop\Context\Item\Iface $context, $classname, $interface) |
|
153 | 153 | { |
154 | - if( isset( self::$objects[$classname] ) ) { |
|
154 | + if (isset(self::$objects[$classname])) { |
|
155 | 155 | return self::$objects[$classname]; |
156 | 156 | } |
157 | 157 | |
158 | - if( class_exists( $classname ) === false ) { |
|
159 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
158 | + if (class_exists($classname) === false) { |
|
159 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname)); |
|
160 | 160 | } |
161 | 161 | |
162 | - $controller = new $classname( $context ); |
|
162 | + $controller = new $classname($context); |
|
163 | 163 | |
164 | - if( !( $controller instanceof $interface ) ) { |
|
165 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface ) ); |
|
164 | + if (!($controller instanceof $interface)) { |
|
165 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $interface)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $controller; |
@@ -28,5 +28,5 @@ |
||
28 | 28 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
29 | 29 | * @return void |
30 | 30 | */ |
31 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ); |
|
31 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context); |
|
32 | 32 | } |
@@ -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 | } |
@@ -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 | $this->basket = $this->domainManager->getSession(); |
42 | 42 | |
43 | 43 | $this->checkLocale(); |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | public function clear() |
51 | 51 | { |
52 | 52 | $this->basket = $this->domainManager->createItem(); |
53 | - $this->domainManager->setSession( $this->basket ); |
|
53 | + $this->domainManager->setSession($this->basket); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | |
@@ -85,50 +85,50 @@ discard block |
||
85 | 85 | * @param string $warehouse Unique code of the warehouse to deliver the products from |
86 | 86 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
87 | 87 | */ |
88 | - public function addProduct( $prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
88 | + public function addProduct($prodid, $quantity = 1, array $options = array(), array $variantAttributeIds = array(), |
|
89 | 89 | array $configAttributeIds = array(), array $hiddenAttributeIds = array(), array $customAttributeValues = array(), |
90 | - $warehouse = 'default' ) |
|
90 | + $warehouse = 'default') |
|
91 | 91 | { |
92 | - $this->checkCategory( $prodid ); |
|
92 | + $this->checkCategory($prodid); |
|
93 | 93 | |
94 | 94 | $context = $this->getContext(); |
95 | 95 | |
96 | - $productItem = $this->getDomainItem( 'product', 'product.id', $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ) ); |
|
96 | + $productItem = $this->getDomainItem('product', 'product.id', $prodid, array('media', 'supplier', 'price', 'product', 'text')); |
|
97 | 97 | |
98 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
99 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
100 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
101 | - $orderBaseProductItem->setWarehouseCode( $warehouse ); |
|
98 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
99 | + $orderBaseProductItem->copyFrom($productItem); |
|
100 | + $orderBaseProductItem->setQuantity($quantity); |
|
101 | + $orderBaseProductItem->setWarehouseCode($warehouse); |
|
102 | 102 | |
103 | 103 | $attr = array(); |
104 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
104 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
105 | 105 | |
106 | - switch( $productItem->getType() ) |
|
106 | + switch ($productItem->getType()) |
|
107 | 107 | { |
108 | 108 | case 'select': |
109 | - $attr = $this->getVariantDetails( $orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options ); |
|
109 | + $attr = $this->getVariantDetails($orderBaseProductItem, $productItem, $prices, $variantAttributeIds, $options); |
|
110 | 110 | break; |
111 | 111 | case 'bundle': |
112 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $warehouse ); |
|
112 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $warehouse); |
|
113 | 113 | break; |
114 | 114 | } |
115 | 115 | |
116 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
117 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
116 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
117 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
118 | 118 | |
119 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ) ); |
|
120 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
121 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
119 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config')); |
|
120 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
121 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
122 | 122 | |
123 | 123 | // remove product rebate of original price in favor to rebates granted for the order |
124 | - $price->setRebate( '0.00' ); |
|
124 | + $price->setRebate('0.00'); |
|
125 | 125 | |
126 | - $orderBaseProductItem->setPrice( $price ); |
|
127 | - $orderBaseProductItem->setAttributes( $attr ); |
|
126 | + $orderBaseProductItem->setPrice($price); |
|
127 | + $orderBaseProductItem->setAttributes($attr); |
|
128 | 128 | |
129 | - $this->addProductInStock( $orderBaseProductItem, $productItem->getId(), $quantity, $options, $warehouse ); |
|
129 | + $this->addProductInStock($orderBaseProductItem, $productItem->getId(), $quantity, $options, $warehouse); |
|
130 | 130 | |
131 | - $this->domainManager->setSession( $this->basket ); |
|
131 | + $this->domainManager->setSession($this->basket); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -137,18 +137,18 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @param integer $position Position number (key) of the order product item |
139 | 139 | */ |
140 | - public function deleteProduct( $position ) |
|
140 | + public function deleteProduct($position) |
|
141 | 141 | { |
142 | - $product = $this->basket->getProduct( $position ); |
|
142 | + $product = $this->basket->getProduct($position); |
|
143 | 143 | |
144 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
144 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
145 | 145 | { |
146 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
147 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
146 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
147 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
148 | 148 | } |
149 | 149 | |
150 | - $this->basket->deleteProduct( $position ); |
|
151 | - $this->domainManager->setSession( $this->basket ); |
|
150 | + $this->basket->deleteProduct($position); |
|
151 | + $this->domainManager->setSession($this->basket); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | |
@@ -161,35 +161,35 @@ discard block |
||
161 | 161 | * The 'stock'=>false option allows adding products without being in stock. |
162 | 162 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
163 | 163 | */ |
164 | - public function editProduct( $position, $quantity, array $options = array(), |
|
165 | - array $configAttributeCodes = array() ) |
|
164 | + public function editProduct($position, $quantity, array $options = array(), |
|
165 | + array $configAttributeCodes = array()) |
|
166 | 166 | { |
167 | - $product = $this->basket->getProduct( $position ); |
|
168 | - $product->setQuantity( $quantity ); // Enforce check immediately |
|
167 | + $product = $this->basket->getProduct($position); |
|
168 | + $product->setQuantity($quantity); // Enforce check immediately |
|
169 | 169 | |
170 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
170 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
171 | 171 | { |
172 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
173 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
172 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
173 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $attributes = $product->getAttributes(); |
177 | - foreach( $attributes as $key => $attribute ) |
|
177 | + foreach ($attributes as $key => $attribute) |
|
178 | 178 | { |
179 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
180 | - unset( $attributes[$key] ); |
|
179 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
180 | + unset($attributes[$key]); |
|
181 | 181 | } |
182 | 182 | } |
183 | - $product->setAttributes( $attributes ); |
|
183 | + $product->setAttributes($attributes); |
|
184 | 184 | |
185 | - $productItem = $this->getDomainItem( 'product', 'product.code', $product->getProductCode(), array( 'price', 'text' ) ); |
|
186 | - $prices = $productItem->getRefItems( 'price', 'default' ); |
|
185 | + $productItem = $this->getDomainItem('product', 'product.code', $product->getProductCode(), array('price', 'text')); |
|
186 | + $prices = $productItem->getRefItems('price', 'default'); |
|
187 | 187 | |
188 | - $product->setPrice( $this->calcPrice( $product, $prices, $quantity ) ); |
|
188 | + $product->setPrice($this->calcPrice($product, $prices, $quantity)); |
|
189 | 189 | |
190 | - $this->editProductInStock( $product, $productItem, $quantity, $position, $options ); |
|
190 | + $this->editProductInStock($product, $productItem, $quantity, $position, $options); |
|
191 | 191 | |
192 | - $this->domainManager->setSession( $this->basket ); |
|
192 | + $this->domainManager->setSession($this->basket); |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | |
@@ -199,50 +199,50 @@ discard block |
||
199 | 199 | * @param string $code Coupon code entered by the user |
200 | 200 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
201 | 201 | */ |
202 | - public function addCoupon( $code ) |
|
202 | + public function addCoupon($code) |
|
203 | 203 | { |
204 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
205 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
204 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
205 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
206 | 206 | |
207 | 207 | |
208 | - $search = $codeManager->createSearch( true ); |
|
208 | + $search = $codeManager->createSearch(true); |
|
209 | 209 | $expr = array( |
210 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
210 | + $search->compare('==', 'coupon.code.code', $code), |
|
211 | 211 | $search->getConditions(), |
212 | 212 | ); |
213 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
214 | - $search->setSlice( 0, 1 ); |
|
213 | + $search->setConditions($search->combine('&&', $expr)); |
|
214 | + $search->setSlice(0, 1); |
|
215 | 215 | |
216 | - $result = $codeManager->searchItems( $search ); |
|
216 | + $result = $codeManager->searchItems($search); |
|
217 | 217 | |
218 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
219 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
218 | + if (($codeItem = reset($result)) === false) { |
|
219 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | |
223 | - $search = $manager->createSearch( true ); |
|
223 | + $search = $manager->createSearch(true); |
|
224 | 224 | $expr = array( |
225 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
225 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
226 | 226 | $search->getConditions(), |
227 | 227 | ); |
228 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
229 | - $search->setSlice( 0, 1 ); |
|
228 | + $search->setConditions($search->combine('&&', $expr)); |
|
229 | + $search->setSlice(0, 1); |
|
230 | 230 | |
231 | - $result = $manager->searchItems( $search ); |
|
231 | + $result = $manager->searchItems($search); |
|
232 | 232 | |
233 | - if( ( $item = reset( $result ) ) === false ) { |
|
234 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
233 | + if (($item = reset($result)) === false) { |
|
234 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
238 | - $provider = $manager->getProvider( $item, $code ); |
|
238 | + $provider = $manager->getProvider($item, $code); |
|
239 | 239 | |
240 | - if( $provider->isAvailable( $this->basket ) !== true ) { |
|
241 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
240 | + if ($provider->isAvailable($this->basket) !== true) { |
|
241 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
242 | 242 | } |
243 | 243 | |
244 | - $provider->addCoupon( $this->basket ); |
|
245 | - $this->domainManager->setSession( $this->basket ); |
|
244 | + $provider->addCoupon($this->basket); |
|
245 | + $this->domainManager->setSession($this->basket); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -252,22 +252,22 @@ discard block |
||
252 | 252 | * @param string $code Coupon code entered by the user |
253 | 253 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
254 | 254 | */ |
255 | - public function deleteCoupon( $code ) |
|
255 | + public function deleteCoupon($code) |
|
256 | 256 | { |
257 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
257 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
258 | 258 | |
259 | 259 | $search = $manager->createSearch(); |
260 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
261 | - $search->setSlice( 0, 1 ); |
|
260 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
261 | + $search->setSlice(0, 1); |
|
262 | 262 | |
263 | - $result = $manager->searchItems( $search ); |
|
263 | + $result = $manager->searchItems($search); |
|
264 | 264 | |
265 | - if( ( $item = reset( $result ) ) === false ) { |
|
266 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
265 | + if (($item = reset($result)) === false) { |
|
266 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
267 | 267 | } |
268 | 268 | |
269 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->basket ); |
|
270 | - $this->domainManager->setSession( $this->basket ); |
|
269 | + $manager->getProvider($item, $code)->deleteCoupon($this->basket); |
|
270 | + $this->domainManager->setSession($this->basket); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | |
@@ -279,31 +279,31 @@ discard block |
||
279 | 279 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
280 | 280 | * if one of the keys is invalid when using an array with key/value pairs |
281 | 281 | */ |
282 | - public function setAddress( $type, $value ) |
|
282 | + public function setAddress($type, $value) |
|
283 | 283 | { |
284 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
285 | - $address->setType( $type ); |
|
284 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
285 | + $address->setType($type); |
|
286 | 286 | |
287 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
287 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
288 | 288 | { |
289 | - $address->copyFrom( $value ); |
|
290 | - $this->basket->setAddress( $address, $type ); |
|
289 | + $address->copyFrom($value); |
|
290 | + $this->basket->setAddress($address, $type); |
|
291 | 291 | } |
292 | - else if( is_array( $value ) ) |
|
292 | + else if (is_array($value)) |
|
293 | 293 | { |
294 | - $this->setAddressFromArray( $address, $value ); |
|
295 | - $this->basket->setAddress( $address, $type ); |
|
294 | + $this->setAddressFromArray($address, $value); |
|
295 | + $this->basket->setAddress($address, $type); |
|
296 | 296 | } |
297 | - else if( $value === null ) |
|
297 | + else if ($value === null) |
|
298 | 298 | { |
299 | - $this->basket->deleteAddress( $type ); |
|
299 | + $this->basket->deleteAddress($type); |
|
300 | 300 | } |
301 | 301 | else |
302 | 302 | { |
303 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
303 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
304 | 304 | } |
305 | 305 | |
306 | - $this->domainManager->setSession( $this->basket ); |
|
306 | + $this->domainManager->setSession($this->basket); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | |
@@ -316,43 +316,43 @@ discard block |
||
316 | 316 | * entered by the customer when choosing one of the delivery or payment options |
317 | 317 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
318 | 318 | */ |
319 | - public function setService( $type, $id, array $attributes = array() ) |
|
319 | + public function setService($type, $id, array $attributes = array()) |
|
320 | 320 | { |
321 | 321 | $context = $this->getContext(); |
322 | 322 | |
323 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
324 | - $serviceItem = $this->getDomainItem( 'service', 'service.id', $id, array( 'media', 'price', 'text' ) ); |
|
323 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
324 | + $serviceItem = $this->getDomainItem('service', 'service.id', $id, array('media', 'price', 'text')); |
|
325 | 325 | |
326 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
327 | - $result = $provider->checkConfigFE( $attributes ); |
|
328 | - $unknown = array_diff_key( $attributes, $result ); |
|
326 | + $provider = $serviceManager->getProvider($serviceItem); |
|
327 | + $result = $provider->checkConfigFE($attributes); |
|
328 | + $unknown = array_diff_key($attributes, $result); |
|
329 | 329 | |
330 | - if( count( $unknown ) > 0 ) |
|
330 | + if (count($unknown) > 0) |
|
331 | 331 | { |
332 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
333 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
332 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
333 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
334 | 334 | } |
335 | 335 | |
336 | - foreach( $result as $key => $value ) |
|
336 | + foreach ($result as $key => $value) |
|
337 | 337 | { |
338 | - if( $value !== null ) { |
|
339 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
338 | + if ($value !== null) { |
|
339 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | |
343 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
343 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
344 | 344 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
345 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
345 | + $orderServiceItem->copyFrom($serviceItem); |
|
346 | 346 | |
347 | - $price = $provider->calcPrice( $this->basket ); |
|
347 | + $price = $provider->calcPrice($this->basket); |
|
348 | 348 | // remove service rebate of original price |
349 | - $price->setRebate( '0.00' ); |
|
350 | - $orderServiceItem->setPrice( $price ); |
|
349 | + $price->setRebate('0.00'); |
|
350 | + $orderServiceItem->setPrice($price); |
|
351 | 351 | |
352 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
352 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
353 | 353 | |
354 | - $this->basket->setService( $orderServiceItem, $type ); |
|
355 | - $this->domainManager->setSession( $this->basket ); |
|
354 | + $this->basket->setService($orderServiceItem, $type); |
|
355 | + $this->domainManager->setSession($this->basket); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | |
@@ -366,32 +366,32 @@ discard block |
||
366 | 366 | * @param string $warehouse Warehouse code for retrieving the stock level |
367 | 367 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there's not enough stock available |
368 | 368 | */ |
369 | - protected function addProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
370 | - $productId, $quantity, array $options, $warehouse ) |
|
369 | + protected function addProductInStock(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
370 | + $productId, $quantity, array $options, $warehouse) |
|
371 | 371 | { |
372 | 372 | $stocklevel = null; |
373 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
374 | - $stocklevel = $this->getStockLevel( $productId, $warehouse ); |
|
373 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
374 | + $stocklevel = $this->getStockLevel($productId, $warehouse); |
|
375 | 375 | } |
376 | 376 | |
377 | - if( $stocklevel === null || $stocklevel > 0 ) |
|
377 | + if ($stocklevel === null || $stocklevel > 0) |
|
378 | 378 | { |
379 | - $position = $this->basket->addProduct( $orderBaseProductItem ); |
|
380 | - $orderBaseProductItem = clone $this->basket->getProduct( $position ); |
|
379 | + $position = $this->basket->addProduct($orderBaseProductItem); |
|
380 | + $orderBaseProductItem = clone $this->basket->getProduct($position); |
|
381 | 381 | $quantity = $orderBaseProductItem->getQuantity(); |
382 | 382 | |
383 | - if( $stocklevel > 0 && $stocklevel < $quantity ) |
|
383 | + if ($stocklevel > 0 && $stocklevel < $quantity) |
|
384 | 384 | { |
385 | - $this->basket->deleteProduct( $position ); |
|
386 | - $orderBaseProductItem->setQuantity( $stocklevel ); |
|
387 | - $this->basket->addProduct( $orderBaseProductItem, $position ); |
|
385 | + $this->basket->deleteProduct($position); |
|
386 | + $orderBaseProductItem->setQuantity($stocklevel); |
|
387 | + $this->basket->addProduct($orderBaseProductItem, $position); |
|
388 | 388 | } |
389 | 389 | } |
390 | 390 | |
391 | - if( $stocklevel !== null && $stocklevel < $quantity ) |
|
391 | + if ($stocklevel !== null && $stocklevel < $quantity) |
|
392 | 392 | { |
393 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $orderBaseProductItem->getName() ); |
|
394 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
393 | + $msg = sprintf('There are not enough products "%1$s" in stock', $orderBaseProductItem->getName()); |
|
394 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 | |
@@ -406,26 +406,26 @@ discard block |
||
406 | 406 | * @param array Associative list of options |
407 | 407 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there's not enough stock available |
408 | 408 | */ |
409 | - protected function editProductInStock( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, |
|
410 | - \Aimeos\MShop\Product\Item\Iface $productItem, $quantity, $position, array $options ) |
|
409 | + protected function editProductInStock(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, |
|
410 | + \Aimeos\MShop\Product\Item\Iface $productItem, $quantity, $position, array $options) |
|
411 | 411 | { |
412 | 412 | $stocklevel = null; |
413 | - if( !isset( $options['stock'] ) || $options['stock'] != false ) { |
|
414 | - $stocklevel = $this->getStockLevel( $productItem->getId(), $product->getWarehouseCode() ); |
|
413 | + if (!isset($options['stock']) || $options['stock'] != false) { |
|
414 | + $stocklevel = $this->getStockLevel($productItem->getId(), $product->getWarehouseCode()); |
|
415 | 415 | } |
416 | 416 | |
417 | - $product->setQuantity( ( $stocklevel !== null && $stocklevel > 0 ? min( $stocklevel, $quantity ) : $quantity ) ); |
|
417 | + $product->setQuantity(($stocklevel !== null && $stocklevel > 0 ? min($stocklevel, $quantity) : $quantity)); |
|
418 | 418 | |
419 | - $this->basket->deleteProduct( $position ); |
|
419 | + $this->basket->deleteProduct($position); |
|
420 | 420 | |
421 | - if( $stocklevel === null || $stocklevel > 0 ) { |
|
422 | - $this->basket->addProduct( $product, $position ); |
|
421 | + if ($stocklevel === null || $stocklevel > 0) { |
|
422 | + $this->basket->addProduct($product, $position); |
|
423 | 423 | } |
424 | 424 | |
425 | - if( $stocklevel !== null && $stocklevel < $quantity ) |
|
425 | + if ($stocklevel !== null && $stocklevel < $quantity) |
|
426 | 426 | { |
427 | - $msg = sprintf( 'There are not enough products "%1$s" in stock', $productItem->getName() ); |
|
428 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
427 | + $msg = sprintf('There are not enough products "%1$s" in stock', $productItem->getName()); |
|
428 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
429 | 429 | } |
430 | 430 | } |
431 | 431 | |
@@ -438,44 +438,44 @@ discard block |
||
438 | 438 | * @param array $variantAttributeIds List of product variant attribute IDs |
439 | 439 | * @param string $warehouse |
440 | 440 | */ |
441 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
442 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $warehouse ) |
|
441 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
442 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $warehouse) |
|
443 | 443 | { |
444 | 444 | $quantity = $orderBaseProductItem->getQuantity(); |
445 | 445 | $products = $subProductIds = $orderProducts = array(); |
446 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
446 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
447 | 447 | |
448 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
448 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
449 | 449 | $subProductIds[] = $item->getId(); |
450 | 450 | } |
451 | 451 | |
452 | - if( count( $subProductIds ) > 0 ) |
|
452 | + if (count($subProductIds) > 0) |
|
453 | 453 | { |
454 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
454 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
455 | 455 | |
456 | - $search = $productManager->createSearch( true ); |
|
456 | + $search = $productManager->createSearch(true); |
|
457 | 457 | $expr = array( |
458 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
458 | + $search->compare('==', 'product.id', $subProductIds), |
|
459 | 459 | $search->getConditions(), |
460 | 460 | ); |
461 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
461 | + $search->setConditions($search->combine('&&', $expr)); |
|
462 | 462 | |
463 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
463 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
464 | 464 | } |
465 | 465 | |
466 | - foreach( $products as $product ) |
|
466 | + foreach ($products as $product) |
|
467 | 467 | { |
468 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
468 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
469 | 469 | |
470 | 470 | $orderProduct = $orderProductManager->createItem(); |
471 | - $orderProduct->copyFrom( $product ); |
|
472 | - $orderProduct->setWarehouseCode( $warehouse ); |
|
473 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
471 | + $orderProduct->copyFrom($product); |
|
472 | + $orderProduct->setWarehouseCode($warehouse); |
|
473 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
474 | 474 | |
475 | 475 | $orderProducts[] = $orderProduct; |
476 | 476 | } |
477 | 477 | |
478 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
478 | + $orderBaseProductItem->setProducts($orderProducts); |
|
479 | 479 | } |
480 | 480 | |
481 | 481 | |
@@ -485,24 +485,24 @@ discard block |
||
485 | 485 | * @param string $prodid Unique ID of the product |
486 | 486 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If product is not associated to at least one category |
487 | 487 | */ |
488 | - protected function checkCategory( $prodid ) |
|
488 | + protected function checkCategory($prodid) |
|
489 | 489 | { |
490 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
490 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
491 | 491 | |
492 | - $search = $catalogListManager->createSearch( true ); |
|
492 | + $search = $catalogListManager->createSearch(true); |
|
493 | 493 | $expr = array( |
494 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
494 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
495 | 495 | $search->getConditions() |
496 | 496 | ); |
497 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
498 | - $search->setSlice( 0, 1 ); |
|
497 | + $search->setConditions($search->combine('&&', $expr)); |
|
498 | + $search->setSlice(0, 1); |
|
499 | 499 | |
500 | - $result = $catalogListManager->searchItems( $search ); |
|
500 | + $result = $catalogListManager->searchItems($search); |
|
501 | 501 | |
502 | - if( reset( $result ) === false ) |
|
502 | + if (reset($result) === false) |
|
503 | 503 | { |
504 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
505 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
504 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
505 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
506 | 506 | } |
507 | 507 | } |
508 | 508 | |
@@ -517,34 +517,34 @@ discard block |
||
517 | 517 | $session = $context->getSession(); |
518 | 518 | $locale = $this->basket->getLocale(); |
519 | 519 | |
520 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
520 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
521 | 521 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
522 | 522 | |
523 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
523 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
524 | 524 | { |
525 | - $locParts = explode( '|', $localeStr ); |
|
526 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
527 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
528 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
525 | + $locParts = explode('|', $localeStr); |
|
526 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
527 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
528 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
529 | 529 | |
530 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
531 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
530 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
531 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
532 | 532 | |
533 | 533 | $context = clone $context; |
534 | - $context->setLocale( $locale ); |
|
534 | + $context->setLocale($locale); |
|
535 | 535 | |
536 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
536 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
537 | 537 | $basket = $manager->getSession(); |
538 | 538 | |
539 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
540 | - $this->copyServices( $basket, $errors ); |
|
541 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
542 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
539 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
540 | + $this->copyServices($basket, $errors); |
|
541 | + $this->copyProducts($basket, $errors, $localeKey); |
|
542 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
543 | 543 | |
544 | - $manager->setSession( $basket ); |
|
544 | + $manager->setSession($basket); |
|
545 | 545 | } |
546 | 546 | |
547 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
547 | + $session->set('aimeos/basket/locale', $localeKey); |
|
548 | 548 | } |
549 | 549 | |
550 | 550 | |
@@ -556,20 +556,20 @@ discard block |
||
556 | 556 | * @param string $localeKey Unique identifier of the site, language and currency |
557 | 557 | * @return array Associative list of errors occured |
558 | 558 | */ |
559 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
559 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
560 | 560 | { |
561 | - foreach( $basket->getAddresses() as $type => $item ) |
|
561 | + foreach ($basket->getAddresses() as $type => $item) |
|
562 | 562 | { |
563 | 563 | try |
564 | 564 | { |
565 | - $this->setAddress( $type, $item->toArray() ); |
|
566 | - $basket->deleteAddress( $type ); |
|
565 | + $this->setAddress($type, $item->toArray()); |
|
566 | + $basket->deleteAddress($type); |
|
567 | 567 | } |
568 | - catch( \Exception $e ) |
|
568 | + catch (\Exception $e) |
|
569 | 569 | { |
570 | 570 | $logger = $this->getContext()->getLogger(); |
571 | 571 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
572 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
572 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
573 | 573 | $errors['address'][$type] = $e->getMessage(); |
574 | 574 | } |
575 | 575 | } |
@@ -586,20 +586,20 @@ discard block |
||
586 | 586 | * @param string $localeKey Unique identifier of the site, language and currency |
587 | 587 | * @return array Associative list of errors occured |
588 | 588 | */ |
589 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
589 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
590 | 590 | { |
591 | - foreach( $basket->getCoupons() as $code => $list ) |
|
591 | + foreach ($basket->getCoupons() as $code => $list) |
|
592 | 592 | { |
593 | 593 | try |
594 | 594 | { |
595 | - $this->addCoupon( $code ); |
|
596 | - $basket->deleteCoupon( $code, true ); |
|
595 | + $this->addCoupon($code); |
|
596 | + $basket->deleteCoupon($code, true); |
|
597 | 597 | } |
598 | - catch( \Exception $e ) |
|
598 | + catch (\Exception $e) |
|
599 | 599 | { |
600 | 600 | $logger = $this->getContext()->getLogger(); |
601 | 601 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
602 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
602 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
603 | 603 | $errors['coupon'][$code] = $e->getMessage(); |
604 | 604 | } |
605 | 605 | } |
@@ -616,11 +616,11 @@ discard block |
||
616 | 616 | * @param string $localeKey Unique identifier of the site, language and currency |
617 | 617 | * @return array Associative list of errors occured |
618 | 618 | */ |
619 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
619 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
620 | 620 | { |
621 | - foreach( $basket->getProducts() as $pos => $product ) |
|
621 | + foreach ($basket->getProducts() as $pos => $product) |
|
622 | 622 | { |
623 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
623 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
624 | 624 | continue; |
625 | 625 | } |
626 | 626 | |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | { |
629 | 629 | $attrIds = array(); |
630 | 630 | |
631 | - foreach( $product->getAttributes() as $attrItem ) { |
|
631 | + foreach ($product->getAttributes() as $attrItem) { |
|
632 | 632 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
633 | 633 | } |
634 | 634 | |
@@ -636,21 +636,21 @@ discard block |
||
636 | 636 | $product->getProductId(), |
637 | 637 | $product->getQuantity(), |
638 | 638 | array(), |
639 | - $this->getValue( $attrIds, 'variant', array() ), |
|
640 | - $this->getValue( $attrIds, 'config', array() ), |
|
641 | - $this->getValue( $attrIds, 'hidden', array() ), |
|
642 | - $this->getValue( $attrIds, 'custom', array() ), |
|
639 | + $this->getValue($attrIds, 'variant', array()), |
|
640 | + $this->getValue($attrIds, 'config', array()), |
|
641 | + $this->getValue($attrIds, 'hidden', array()), |
|
642 | + $this->getValue($attrIds, 'custom', array()), |
|
643 | 643 | $product->getWarehouseCode() |
644 | 644 | ); |
645 | 645 | |
646 | - $basket->deleteProduct( $pos ); |
|
646 | + $basket->deleteProduct($pos); |
|
647 | 647 | } |
648 | - catch( \Exception $e ) |
|
648 | + catch (\Exception $e) |
|
649 | 649 | { |
650 | 650 | $code = $product->getProductCode(); |
651 | 651 | $logger = $this->getContext()->getLogger(); |
652 | 652 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
653 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
653 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
654 | 654 | $errors['product'][$pos] = $e->getMessage(); |
655 | 655 | } |
656 | 656 | } |
@@ -666,22 +666,22 @@ discard block |
||
666 | 666 | * @param array $errors Associative list of previous errors |
667 | 667 | * @return array Associative list of errors occured |
668 | 668 | */ |
669 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
669 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
670 | 670 | { |
671 | - foreach( $basket->getServices() as $type => $item ) |
|
671 | + foreach ($basket->getServices() as $type => $item) |
|
672 | 672 | { |
673 | 673 | try |
674 | 674 | { |
675 | 675 | $attributes = array(); |
676 | 676 | |
677 | - foreach( $item->getAttributes() as $attrItem ) { |
|
677 | + foreach ($item->getAttributes() as $attrItem) { |
|
678 | 678 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
679 | 679 | } |
680 | 680 | |
681 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
682 | - $basket->deleteService( $type ); |
|
681 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
682 | + $basket->deleteService($type); |
|
683 | 683 | } |
684 | - catch( \Exception $e ) {; } // Don't notify the user as appropriate services can be added automatically |
|
684 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
685 | 685 | } |
686 | 686 | |
687 | 687 | return $errors; |
@@ -697,30 +697,30 @@ discard block |
||
697 | 697 | * @param array $refIds List of IDs that must be associated to the product |
698 | 698 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
699 | 699 | */ |
700 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
700 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
701 | 701 | { |
702 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
703 | - $search = $productManager->createSearch( true ); |
|
702 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
703 | + $search = $productManager->createSearch(true); |
|
704 | 704 | |
705 | 705 | $expr = array( |
706 | - $search->compare( '==', 'product.id', $prodId ), |
|
706 | + $search->compare('==', 'product.id', $prodId), |
|
707 | 707 | $search->getConditions(), |
708 | 708 | ); |
709 | 709 | |
710 | - if( count( $refIds ) > 0 ) |
|
710 | + if (count($refIds) > 0) |
|
711 | 711 | { |
712 | - $param = array( $domain, $listTypeId, $refIds ); |
|
713 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
712 | + $param = array($domain, $listTypeId, $refIds); |
|
713 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
714 | 714 | |
715 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
715 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
716 | 716 | } |
717 | 717 | |
718 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
718 | + $search->setConditions($search->combine('&&', $expr)); |
|
719 | 719 | |
720 | - if( count( $productManager->searchItems( $search, array() ) ) === 0 ) |
|
720 | + if (count($productManager->searchItems($search, array())) === 0) |
|
721 | 721 | { |
722 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId ); |
|
723 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
722 | + $msg = sprintf('Invalid "%1$s" references for product with ID "%2$s"', $domain, $prodId); |
|
723 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
724 | 724 | } |
725 | 725 | } |
726 | 726 | |
@@ -732,35 +732,35 @@ discard block |
||
732 | 732 | * @param string $warehouse Unique code of the warehouse |
733 | 733 | * @return integer|null Number of available items in stock (null for unlimited stock) |
734 | 734 | */ |
735 | - protected function getStockLevel( $prodid, $warehouse ) |
|
735 | + protected function getStockLevel($prodid, $warehouse) |
|
736 | 736 | { |
737 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/stock' ); |
|
737 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/stock'); |
|
738 | 738 | |
739 | - $search = $manager->createSearch( true ); |
|
739 | + $search = $manager->createSearch(true); |
|
740 | 740 | $expr = array( |
741 | - $search->compare( '==', 'product.stock.parentid', $prodid ), |
|
741 | + $search->compare('==', 'product.stock.parentid', $prodid), |
|
742 | 742 | $search->getConditions(), |
743 | - $search->compare( '==', 'product.stock.warehouse.code', $warehouse ), |
|
743 | + $search->compare('==', 'product.stock.warehouse.code', $warehouse), |
|
744 | 744 | ); |
745 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
745 | + $search->setConditions($search->combine('&&', $expr)); |
|
746 | 746 | |
747 | - $result = $manager->searchItems( $search ); |
|
747 | + $result = $manager->searchItems($search); |
|
748 | 748 | |
749 | - if( empty( $result ) ) |
|
749 | + if (empty($result)) |
|
750 | 750 | { |
751 | - $msg = sprintf( 'No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse ); |
|
752 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
751 | + $msg = sprintf('No stock for product ID "%1$s" and warehouse "%2$s" available', $prodid, $warehouse); |
|
752 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | $stocklevel = null; |
756 | 756 | |
757 | - foreach( $result as $item ) |
|
757 | + foreach ($result as $item) |
|
758 | 758 | { |
759 | - if( ( $stock = $item->getStockLevel() ) === null ) { |
|
759 | + if (($stock = $item->getStockLevel()) === null) { |
|
760 | 760 | return null; |
761 | 761 | } |
762 | 762 | |
763 | - $stocklevel = max( (int) $stocklevel, $item->getStockLevel() ); |
|
763 | + $stocklevel = max((int) $stocklevel, $item->getStockLevel()); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | return $stocklevel; |
@@ -778,36 +778,36 @@ discard block |
||
778 | 778 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
779 | 779 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
780 | 780 | */ |
781 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
782 | - array $attributeIds, $type, array $attributeValues = array() ) |
|
781 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
782 | + array $attributeIds, $type, array $attributeValues = array()) |
|
783 | 783 | { |
784 | - if( empty( $attributeIds ) ) { |
|
784 | + if (empty($attributeIds)) { |
|
785 | 785 | return array(); |
786 | 786 | } |
787 | 787 | |
788 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
789 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
788 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
789 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
790 | 790 | |
791 | 791 | $list = array(); |
792 | 792 | $context = $this->getContext(); |
793 | 793 | |
794 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
795 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
794 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
795 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
796 | 796 | |
797 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
797 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
798 | 798 | { |
799 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
799 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
800 | 800 | |
801 | - if( !empty( $prices ) ) { |
|
802 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
801 | + if (!empty($prices)) { |
|
802 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
803 | 803 | } |
804 | 804 | |
805 | 805 | $item = $orderProductAttributeManager->createItem(); |
806 | - $item->copyFrom( $attrItem ); |
|
807 | - $item->setType( $type ); |
|
806 | + $item->copyFrom($attrItem); |
|
807 | + $item->setType($type); |
|
808 | 808 | |
809 | - if( isset( $attributeValues[$id] ) ) { |
|
810 | - $item->setValue( $attributeValues[$id] ); |
|
809 | + if (isset($attributeValues[$id])) { |
|
810 | + $item->setValue($attributeValues[$id]); |
|
811 | 811 | } |
812 | 812 | |
813 | 813 | $list[] = $item; |
@@ -825,18 +825,18 @@ discard block |
||
825 | 825 | * an address item. |
826 | 826 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
827 | 827 | */ |
828 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
828 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
829 | 829 | { |
830 | - foreach( $map as $key => $value ) { |
|
831 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
830 | + foreach ($map as $key => $value) { |
|
831 | + $map[$key] = strip_tags($value); // prevent XSS |
|
832 | 832 | } |
833 | 833 | |
834 | - $errors = $address->fromArray( $map ); |
|
834 | + $errors = $address->fromArray($map); |
|
835 | 835 | |
836 | - if( count( $errors ) > 0 ) |
|
836 | + if (count($errors) > 0) |
|
837 | 837 | { |
838 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
839 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
838 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
839 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
840 | 840 | } |
841 | 841 | } |
842 | 842 | |
@@ -847,31 +847,31 @@ discard block |
||
847 | 847 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
848 | 848 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
849 | 849 | */ |
850 | - protected function getAttributeItems( array $orderAttributes ) |
|
850 | + protected function getAttributeItems(array $orderAttributes) |
|
851 | 851 | { |
852 | - if( empty( $orderAttributes ) ) { |
|
852 | + if (empty($orderAttributes)) { |
|
853 | 853 | return array(); |
854 | 854 | } |
855 | 855 | |
856 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
857 | - $search = $attributeManager->createSearch( true ); |
|
856 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
857 | + $search = $attributeManager->createSearch(true); |
|
858 | 858 | $expr = array(); |
859 | 859 | |
860 | - foreach( $orderAttributes as $item ) |
|
860 | + foreach ($orderAttributes as $item) |
|
861 | 861 | { |
862 | 862 | $tmp = array( |
863 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
864 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
865 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
866 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
867 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
863 | + $search->compare('==', 'attribute.domain', 'product'), |
|
864 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
865 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
866 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
867 | + $search->compare('>', 'attribute.type.status', 0), |
|
868 | 868 | $search->getConditions(), |
869 | 869 | ); |
870 | - $expr[] = $search->combine( '&&', $tmp ); |
|
870 | + $expr[] = $search->combine('&&', $tmp); |
|
871 | 871 | } |
872 | 872 | |
873 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
874 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
873 | + $search->setConditions($search->combine('||', $expr)); |
|
874 | + return $attributeManager->searchItems($search, array('price')); |
|
875 | 875 | } |
876 | 876 | |
877 | 877 | |
@@ -883,31 +883,31 @@ discard block |
||
883 | 883 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
884 | 884 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
885 | 885 | */ |
886 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
886 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
887 | 887 | { |
888 | - if( empty( $attributeIds ) ) { |
|
888 | + if (empty($attributeIds)) { |
|
889 | 889 | return array(); |
890 | 890 | } |
891 | 891 | |
892 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
892 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
893 | 893 | |
894 | - $search = $attributeManager->createSearch( true ); |
|
894 | + $search = $attributeManager->createSearch(true); |
|
895 | 895 | $expr = array( |
896 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
896 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
897 | 897 | $search->getConditions(), |
898 | 898 | ); |
899 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
900 | - $search->setSlice( 0, 0x7fffffff ); |
|
899 | + $search->setConditions($search->combine('&&', $expr)); |
|
900 | + $search->setSlice(0, 0x7fffffff); |
|
901 | 901 | |
902 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
902 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
903 | 903 | |
904 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
904 | + if (count($attrItems) !== count($attributeIds)) |
|
905 | 905 | { |
906 | - $expected = implode( ',', $attributeIds ); |
|
907 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
908 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
906 | + $expected = implode(',', $attributeIds); |
|
907 | + $actual = implode(',', array_keys($attrItems)); |
|
908 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
909 | 909 | |
910 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
910 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
911 | 911 | } |
912 | 912 | |
913 | 913 | return $attrItems; |
@@ -922,32 +922,32 @@ discard block |
||
922 | 922 | * @param integer $quantity New product quantity |
923 | 923 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
924 | 924 | */ |
925 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
925 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
926 | 926 | { |
927 | 927 | $context = $this->getContext(); |
928 | 928 | |
929 | - if( empty( $prices ) ) |
|
929 | + if (empty($prices)) |
|
930 | 930 | { |
931 | - $parentItem = $this->getDomainItem( 'product', 'product.id', $product->getProductId(), array( 'price' ) ); |
|
932 | - $prices = $parentItem->getRefItems( 'price', 'default' ); |
|
931 | + $parentItem = $this->getDomainItem('product', 'product.id', $product->getProductId(), array('price')); |
|
932 | + $prices = $parentItem->getRefItems('price', 'default'); |
|
933 | 933 | } |
934 | 934 | |
935 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
936 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
935 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
936 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
937 | 937 | |
938 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
938 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
939 | 939 | { |
940 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
940 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
941 | 941 | |
942 | - if( count( $prices ) > 0 ) |
|
942 | + if (count($prices) > 0) |
|
943 | 943 | { |
944 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
945 | - $price->addItem( $attrPrice ); |
|
944 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
945 | + $price->addItem($attrPrice); |
|
946 | 946 | } |
947 | 947 | } |
948 | 948 | |
949 | 949 | // remove product rebate of original price in favor to rebates granted for the order |
950 | - $price->setRebate( '0.00' ); |
|
950 | + $price->setRebate('0.00'); |
|
951 | 951 | |
952 | 952 | return $price; |
953 | 953 | } |
@@ -963,23 +963,23 @@ discard block |
||
963 | 963 | * @return \Aimeos\MShop\Common\Item\Iface Domain item object |
964 | 964 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
965 | 965 | */ |
966 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
966 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
967 | 967 | { |
968 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
968 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
969 | 969 | |
970 | - $search = $manager->createSearch( true ); |
|
970 | + $search = $manager->createSearch(true); |
|
971 | 971 | $expr = array( |
972 | - $search->compare( '==', $key, $value ), |
|
972 | + $search->compare('==', $key, $value), |
|
973 | 973 | $search->getConditions(), |
974 | 974 | ); |
975 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
975 | + $search->setConditions($search->combine('&&', $expr)); |
|
976 | 976 | |
977 | - $result = $manager->searchItems( $search, $ref ); |
|
977 | + $result = $manager->searchItems($search, $ref); |
|
978 | 978 | |
979 | - if( ( $item = reset( $result ) ) === false ) |
|
979 | + if (($item = reset($result)) === false) |
|
980 | 980 | { |
981 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
982 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
981 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
982 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
983 | 983 | } |
984 | 984 | |
985 | 985 | return $item; |
@@ -993,26 +993,26 @@ discard block |
||
993 | 993 | * @param string $code Code of the list type |
994 | 994 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
995 | 995 | */ |
996 | - protected function getProductListTypeItem( $domain, $code ) |
|
996 | + protected function getProductListTypeItem($domain, $code) |
|
997 | 997 | { |
998 | - if( !isset( $this->listTypeAttributes[$domain][$code] ) ) |
|
998 | + if (!isset($this->listTypeAttributes[$domain][$code])) |
|
999 | 999 | { |
1000 | - $listTypeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
1000 | + $listTypeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
1001 | 1001 | |
1002 | - $listTypeSearch = $listTypeManager->createSearch( true ); |
|
1002 | + $listTypeSearch = $listTypeManager->createSearch(true); |
|
1003 | 1003 | $expr = array( |
1004 | - $listTypeSearch->compare( '==', 'product.lists.type.domain', $domain ), |
|
1005 | - $listTypeSearch->compare( '==', 'product.lists.type.code', $code ), |
|
1004 | + $listTypeSearch->compare('==', 'product.lists.type.domain', $domain), |
|
1005 | + $listTypeSearch->compare('==', 'product.lists.type.code', $code), |
|
1006 | 1006 | $listTypeSearch->getConditions(), |
1007 | 1007 | ); |
1008 | - $listTypeSearch->setConditions( $listTypeSearch->combine( '&&', $expr ) ); |
|
1008 | + $listTypeSearch->setConditions($listTypeSearch->combine('&&', $expr)); |
|
1009 | 1009 | |
1010 | - $listTypeItems = $listTypeManager->searchItems( $listTypeSearch ); |
|
1010 | + $listTypeItems = $listTypeManager->searchItems($listTypeSearch); |
|
1011 | 1011 | |
1012 | - if( ( $listTypeItem = reset( $listTypeItems ) ) === false ) |
|
1012 | + if (($listTypeItem = reset($listTypeItems)) === false) |
|
1013 | 1013 | { |
1014 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
1015 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
1014 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
1015 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | $this->listTypeAttributes[$domain][$code] = $listTypeItem; |
@@ -1030,39 +1030,39 @@ discard block |
||
1030 | 1030 | * @param array $domains Names of the domain items that should be fetched too |
1031 | 1031 | * @return array List of products matching the given attributes |
1032 | 1032 | */ |
1033 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
1034 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
1033 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
1034 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
1035 | 1035 | { |
1036 | 1036 | $subProductIds = array(); |
1037 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
1037 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
1038 | 1038 | $subProductIds[] = $item->getId(); |
1039 | 1039 | } |
1040 | 1040 | |
1041 | - if( count( $subProductIds ) === 0 ) { |
|
1041 | + if (count($subProductIds) === 0) { |
|
1042 | 1042 | return array(); |
1043 | 1043 | } |
1044 | 1044 | |
1045 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
1046 | - $search = $productManager->createSearch( true ); |
|
1045 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
1046 | + $search = $productManager->createSearch(true); |
|
1047 | 1047 | |
1048 | 1048 | $expr = array( |
1049 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
1049 | + $search->compare('==', 'product.id', $subProductIds), |
|
1050 | 1050 | $search->getConditions(), |
1051 | 1051 | ); |
1052 | 1052 | |
1053 | - if( count( $variantAttributeIds ) > 0 ) |
|
1053 | + if (count($variantAttributeIds) > 0) |
|
1054 | 1054 | { |
1055 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
1055 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
1056 | 1056 | |
1057 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
1058 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
1057 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
1058 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
1059 | 1059 | |
1060 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
1060 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
1061 | 1061 | } |
1062 | 1062 | |
1063 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
1063 | + $search->setConditions($search->combine('&&', $expr)); |
|
1064 | 1064 | |
1065 | - return $productManager->searchItems( $search, $domains ); |
|
1065 | + return $productManager->searchItems($search, $domains); |
|
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
@@ -1077,44 +1077,44 @@ discard block |
||
1077 | 1077 | * @return \Aimeos\MShop\Order\Item\Base\Product\Attribute\Iface[] List of order product attributes |
1078 | 1078 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If no product variant is found |
1079 | 1079 | */ |
1080 | - protected function getVariantDetails( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
1081 | - \Aimeos\MShop\Product\Item\Iface &$productItem, array &$prices, array $variantAttributeIds, array $options ) |
|
1080 | + protected function getVariantDetails(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
1081 | + \Aimeos\MShop\Product\Item\Iface & $productItem, array &$prices, array $variantAttributeIds, array $options) |
|
1082 | 1082 | { |
1083 | 1083 | $attr = array(); |
1084 | - $productItems = $this->getProductVariants( $productItem, $variantAttributeIds ); |
|
1084 | + $productItems = $this->getProductVariants($productItem, $variantAttributeIds); |
|
1085 | 1085 | |
1086 | - if( count( $productItems ) > 1 ) |
|
1086 | + if (count($productItems) > 1) |
|
1087 | 1087 | { |
1088 | - $msg = sprintf( 'No unique article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
1089 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
1088 | + $msg = sprintf('No unique article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
1089 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
1090 | 1090 | } |
1091 | - else if( ( $result = reset( $productItems ) ) !== false ) // count == 1 |
|
1091 | + else if (($result = reset($productItems)) !== false) // count == 1 |
|
1092 | 1092 | { |
1093 | 1093 | $productItem = $result; |
1094 | - $orderBaseProductItem->setProductCode( $productItem->getCode() ); |
|
1094 | + $orderBaseProductItem->setProductCode($productItem->getCode()); |
|
1095 | 1095 | |
1096 | - $subprices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
1096 | + $subprices = $productItem->getRefItems('price', 'default', 'default'); |
|
1097 | 1097 | |
1098 | - if( count( $subprices ) > 0 ) { |
|
1098 | + if (count($subprices) > 0) { |
|
1099 | 1099 | $prices = $subprices; |
1100 | 1100 | } |
1101 | 1101 | |
1102 | - $orderProductAttrManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
1103 | - $variantAttributes = $productItem->getRefItems( 'attribute', null, 'variant' ); |
|
1102 | + $orderProductAttrManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
1103 | + $variantAttributes = $productItem->getRefItems('attribute', null, 'variant'); |
|
1104 | 1104 | |
1105 | - foreach( $this->getAttributes( array_keys( $variantAttributes ), array( 'text' ) ) as $attrItem ) |
|
1105 | + foreach ($this->getAttributes(array_keys($variantAttributes), array('text')) as $attrItem) |
|
1106 | 1106 | { |
1107 | 1107 | $orderAttributeItem = $orderProductAttrManager->createItem(); |
1108 | - $orderAttributeItem->copyFrom( $attrItem ); |
|
1109 | - $orderAttributeItem->setType( 'variant' ); |
|
1108 | + $orderAttributeItem->copyFrom($attrItem); |
|
1109 | + $orderAttributeItem->setType('variant'); |
|
1110 | 1110 | |
1111 | 1111 | $attr[] = $orderAttributeItem; |
1112 | 1112 | } |
1113 | 1113 | } |
1114 | - else if( !isset( $options['variant'] ) || $options['variant'] != false ) // count == 0 |
|
1114 | + else if (!isset($options['variant']) || $options['variant'] != false) // count == 0 |
|
1115 | 1115 | { |
1116 | - $msg = sprintf( 'No article found for selected attributes and product ID "%1$s"', $productItem->getId() ); |
|
1117 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
1116 | + $msg = sprintf('No article found for selected attributes and product ID "%1$s"', $productItem->getId()); |
|
1117 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | return $attr; |
@@ -1129,9 +1129,9 @@ discard block |
||
1129 | 1129 | * @param mixed $default Default value if no value is available for the given name |
1130 | 1130 | * @return mixed Value from the array or default value |
1131 | 1131 | */ |
1132 | - protected function getValue( array $values, $name, $default = null ) |
|
1132 | + protected function getValue(array $values, $name, $default = null) |
|
1133 | 1133 | { |
1134 | - if( isset( $values[$name] ) ) { |
|
1134 | + if (isset($values[$name])) { |
|
1135 | 1135 | return $values[$name]; |
1136 | 1136 | } |
1137 | 1137 |
@@ -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 |
@@ -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 | } |