@@ -31,46 +31,46 @@ discard block |
||
31 | 31 | * @param integer $quantity New product quantity |
32 | 32 | * @return \Aimeos\MShop\Price\Item\Iface Price item with calculated price |
33 | 33 | */ |
34 | - protected function calcPrice( \Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity ) |
|
34 | + protected function calcPrice(\Aimeos\MShop\Order\Item\Base\Product\Iface $product, array $prices, $quantity) |
|
35 | 35 | { |
36 | 36 | $context = $this->getContext(); |
37 | 37 | |
38 | - if( empty( $prices ) ) |
|
38 | + if (empty($prices)) |
|
39 | 39 | { |
40 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
41 | - $prices = $manager->getItem( $product->getProductId(), array( 'price' ) )->getRefItems( 'price', 'default' ); |
|
40 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
41 | + $prices = $manager->getItem($product->getProductId(), array('price'))->getRefItems('price', 'default'); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
46 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
45 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
46 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
47 | 47 | |
48 | 48 | // customers can pay what they would like to pay |
49 | - if( ( $attr = $product->getAttributeItem( 'price', 'custom' ) ) !== null ) |
|
49 | + if (($attr = $product->getAttributeItem('price', 'custom')) !== null) |
|
50 | 50 | { |
51 | 51 | $amount = $attr->getValue(); |
52 | 52 | |
53 | - if( preg_match( '/^[0-9]*(\.[0-9]+)?$/', $amount ) !== 1 || ((double) $amount) < 0.01 ) { |
|
54 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid price value "%1$s"', $amount ) ); |
|
53 | + if (preg_match('/^[0-9]*(\.[0-9]+)?$/', $amount) !== 1 || ((double) $amount) < 0.01) { |
|
54 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid price value "%1$s"', $amount)); |
|
55 | 55 | } |
56 | 56 | |
57 | - $price->setValue( $amount ); |
|
57 | + $price->setValue($amount); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // add prices of (optional) attributes |
61 | - foreach( $this->getAttributeItems( $product->getAttributes() ) as $attrItem ) |
|
61 | + foreach ($this->getAttributeItems($product->getAttributes()) as $attrItem) |
|
62 | 62 | { |
63 | - $prices = $attrItem->getRefItems( 'price', 'default' ); |
|
63 | + $prices = $attrItem->getRefItems('price', 'default'); |
|
64 | 64 | |
65 | - if( count( $prices ) > 0 ) |
|
65 | + if (count($prices) > 0) |
|
66 | 66 | { |
67 | - $attrPrice = $priceManager->getLowestPrice( $prices, $quantity ); |
|
68 | - $price->addItem( $attrPrice ); |
|
67 | + $attrPrice = $priceManager->getLowestPrice($prices, $quantity); |
|
68 | + $price->addItem($attrPrice); |
|
69 | 69 | } |
70 | 70 | } |
71 | 71 | |
72 | 72 | // remove product rebate of original price in favor to rebates granted for the order |
73 | - $price->setRebate( '0.00' ); |
|
73 | + $price->setRebate('0.00'); |
|
74 | 74 | |
75 | 75 | return $price; |
76 | 76 | } |
@@ -84,42 +84,42 @@ discard block |
||
84 | 84 | * @param array $refMap Associative list of list type codes as keys and lists of reference IDs as values |
85 | 85 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
86 | 86 | */ |
87 | - protected function checkListRef( $prodId, $domain, array $refMap ) |
|
87 | + protected function checkListRef($prodId, $domain, array $refMap) |
|
88 | 88 | { |
89 | - if( empty( $refMap ) ) { |
|
89 | + if (empty($refMap)) { |
|
90 | 90 | return; |
91 | 91 | } |
92 | 92 | |
93 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
94 | - $search = $productManager->createSearch( true ); |
|
93 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
94 | + $search = $productManager->createSearch(true); |
|
95 | 95 | |
96 | 96 | $expr = array( |
97 | - $search->compare( '==', 'product.id', $prodId ), |
|
97 | + $search->compare('==', 'product.id', $prodId), |
|
98 | 98 | $search->getConditions(), |
99 | 99 | ); |
100 | 100 | |
101 | - foreach( $refMap as $listType => $refIds ) |
|
101 | + foreach ($refMap as $listType => $refIds) |
|
102 | 102 | { |
103 | - if( empty( $refIds ) ) { |
|
103 | + if (empty($refIds)) { |
|
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | - foreach( $refIds as $key => $refId ) { |
|
107 | + foreach ($refIds as $key => $refId) { |
|
108 | 108 | $refIds[$key] = (string) $refId; |
109 | 109 | } |
110 | 110 | |
111 | - $param = array( $domain, $this->getProductListTypeItem( $domain, $listType )->getId(), $refIds ); |
|
112 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
111 | + $param = array($domain, $this->getProductListTypeItem($domain, $listType)->getId(), $refIds); |
|
112 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
113 | 113 | |
114 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
114 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
115 | 115 | } |
116 | 116 | |
117 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
117 | + $search->setConditions($search->combine('&&', $expr)); |
|
118 | 118 | |
119 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
119 | + if (count($productManager->searchItems($search, [])) === 0) |
|
120 | 120 | { |
121 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
122 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
121 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
122 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
123 | 123 | } |
124 | 124 | } |
125 | 125 | |
@@ -134,34 +134,34 @@ discard block |
||
134 | 134 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If one or more of the IDs are not associated |
135 | 135 | * @deprecated Use checkListRef() instead |
136 | 136 | */ |
137 | - protected function checkReferences( $prodId, $domain, $listTypeId, array $refIds ) |
|
137 | + protected function checkReferences($prodId, $domain, $listTypeId, array $refIds) |
|
138 | 138 | { |
139 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
140 | - $search = $productManager->createSearch( true ); |
|
139 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
140 | + $search = $productManager->createSearch(true); |
|
141 | 141 | |
142 | 142 | $expr = array( |
143 | - $search->compare( '==', 'product.id', $prodId ), |
|
143 | + $search->compare('==', 'product.id', $prodId), |
|
144 | 144 | $search->getConditions(), |
145 | 145 | ); |
146 | 146 | |
147 | - if( count( $refIds ) > 0 ) |
|
147 | + if (count($refIds) > 0) |
|
148 | 148 | { |
149 | - foreach( $refIds as $key => $refId ) { |
|
149 | + foreach ($refIds as $key => $refId) { |
|
150 | 150 | $refIds[$key] = (string) $refId; |
151 | 151 | } |
152 | 152 | |
153 | - $param = array( $domain, $listTypeId, $refIds ); |
|
154 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
153 | + $param = array($domain, $listTypeId, $refIds); |
|
154 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
155 | 155 | |
156 | - $expr[] = $search->compare( '==', $cmpfunc, count( $refIds ) ); |
|
156 | + $expr[] = $search->compare('==', $cmpfunc, count($refIds)); |
|
157 | 157 | } |
158 | 158 | |
159 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
159 | + $search->setConditions($search->combine('&&', $expr)); |
|
160 | 160 | |
161 | - if( count( $productManager->searchItems( $search, [] ) ) === 0 ) |
|
161 | + if (count($productManager->searchItems($search, [])) === 0) |
|
162 | 162 | { |
163 | - $msg = sprintf( 'Invalid "%1$s" references for product with ID %2$s', $domain, json_encode( $prodId ) ); |
|
164 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
163 | + $msg = sprintf('Invalid "%1$s" references for product with ID %2$s', $domain, json_encode($prodId)); |
|
164 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
165 | 165 | } |
166 | 166 | } |
167 | 167 | |
@@ -171,41 +171,41 @@ discard block |
||
171 | 171 | * |
172 | 172 | * @param string $type Basket type |
173 | 173 | */ |
174 | - protected function checkLocale( $type ) |
|
174 | + protected function checkLocale($type) |
|
175 | 175 | { |
176 | 176 | $errors = []; |
177 | 177 | $context = $this->getContext(); |
178 | 178 | $session = $context->getSession(); |
179 | 179 | $locale = $this->get()->getLocale(); |
180 | 180 | |
181 | - $localeStr = $session->get( 'aimeos/basket/locale' ); |
|
181 | + $localeStr = $session->get('aimeos/basket/locale'); |
|
182 | 182 | $localeKey = $locale->getSite()->getCode() . '|' . $locale->getLanguageId() . '|' . $locale->getCurrencyId(); |
183 | 183 | |
184 | - if( $localeStr !== null && $localeStr !== $localeKey ) |
|
184 | + if ($localeStr !== null && $localeStr !== $localeKey) |
|
185 | 185 | { |
186 | - $locParts = explode( '|', $localeStr ); |
|
187 | - $locSite = ( isset( $locParts[0] ) ? $locParts[0] : '' ); |
|
188 | - $locLanguage = ( isset( $locParts[1] ) ? $locParts[1] : '' ); |
|
189 | - $locCurrency = ( isset( $locParts[2] ) ? $locParts[2] : '' ); |
|
186 | + $locParts = explode('|', $localeStr); |
|
187 | + $locSite = (isset($locParts[0]) ? $locParts[0] : ''); |
|
188 | + $locLanguage = (isset($locParts[1]) ? $locParts[1] : ''); |
|
189 | + $locCurrency = (isset($locParts[2]) ? $locParts[2] : ''); |
|
190 | 190 | |
191 | - $localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' ); |
|
192 | - $locale = $localeManager->bootstrap( $locSite, $locLanguage, $locCurrency, false ); |
|
191 | + $localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale'); |
|
192 | + $locale = $localeManager->bootstrap($locSite, $locLanguage, $locCurrency, false); |
|
193 | 193 | |
194 | 194 | $context = clone $context; |
195 | - $context->setLocale( $locale ); |
|
195 | + $context->setLocale($locale); |
|
196 | 196 | |
197 | - $manager = \Aimeos\MShop\Order\Manager\Factory::createManager( $context )->getSubManager( 'base' ); |
|
198 | - $basket = $manager->getSession( $type ); |
|
197 | + $manager = \Aimeos\MShop\Order\Manager\Factory::createManager($context)->getSubManager('base'); |
|
198 | + $basket = $manager->getSession($type); |
|
199 | 199 | |
200 | - $this->copyAddresses( $basket, $errors, $localeKey ); |
|
201 | - $this->copyServices( $basket, $errors ); |
|
202 | - $this->copyProducts( $basket, $errors, $localeKey ); |
|
203 | - $this->copyCoupons( $basket, $errors, $localeKey ); |
|
200 | + $this->copyAddresses($basket, $errors, $localeKey); |
|
201 | + $this->copyServices($basket, $errors); |
|
202 | + $this->copyProducts($basket, $errors, $localeKey); |
|
203 | + $this->copyCoupons($basket, $errors, $localeKey); |
|
204 | 204 | |
205 | - $manager->setSession( $basket, $type ); |
|
205 | + $manager->setSession($basket, $type); |
|
206 | 206 | } |
207 | 207 | |
208 | - $session->set( 'aimeos/basket/locale', $localeKey ); |
|
208 | + $session->set('aimeos/basket/locale', $localeKey); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | |
@@ -217,20 +217,20 @@ discard block |
||
217 | 217 | * @param string $localeKey Unique identifier of the site, language and currency |
218 | 218 | * @return array Associative list of errors occured |
219 | 219 | */ |
220 | - protected function copyAddresses( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
220 | + protected function copyAddresses(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
221 | 221 | { |
222 | - foreach( $basket->getAddresses() as $type => $item ) |
|
222 | + foreach ($basket->getAddresses() as $type => $item) |
|
223 | 223 | { |
224 | 224 | try |
225 | 225 | { |
226 | - $this->setAddress( $type, $item->toArray() ); |
|
227 | - $basket->deleteAddress( $type ); |
|
226 | + $this->setAddress($type, $item->toArray()); |
|
227 | + $basket->deleteAddress($type); |
|
228 | 228 | } |
229 | - catch( \Exception $e ) |
|
229 | + catch (\Exception $e) |
|
230 | 230 | { |
231 | 231 | $logger = $this->getContext()->getLogger(); |
232 | 232 | $str = 'Error migrating address with type "%1$s" in basket to locale "%2$s": %3$s'; |
233 | - $logger->log( sprintf( $str, $type, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
233 | + $logger->log(sprintf($str, $type, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
234 | 234 | $errors['address'][$type] = $e->getMessage(); |
235 | 235 | } |
236 | 236 | } |
@@ -247,20 +247,20 @@ discard block |
||
247 | 247 | * @param string $localeKey Unique identifier of the site, language and currency |
248 | 248 | * @return array Associative list of errors occured |
249 | 249 | */ |
250 | - protected function copyCoupons( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
250 | + protected function copyCoupons(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
251 | 251 | { |
252 | - foreach( $basket->getCoupons() as $code => $list ) |
|
252 | + foreach ($basket->getCoupons() as $code => $list) |
|
253 | 253 | { |
254 | 254 | try |
255 | 255 | { |
256 | - $this->addCoupon( $code ); |
|
257 | - $basket->deleteCoupon( $code, true ); |
|
256 | + $this->addCoupon($code); |
|
257 | + $basket->deleteCoupon($code, true); |
|
258 | 258 | } |
259 | - catch( \Exception $e ) |
|
259 | + catch (\Exception $e) |
|
260 | 260 | { |
261 | 261 | $logger = $this->getContext()->getLogger(); |
262 | 262 | $str = 'Error migrating coupon with code "%1$s" in basket to locale "%2$s": %3$s'; |
263 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
263 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
264 | 264 | $errors['coupon'][$code] = $e->getMessage(); |
265 | 265 | } |
266 | 266 | } |
@@ -277,11 +277,11 @@ discard block |
||
277 | 277 | * @param string $localeKey Unique identifier of the site, language and currency |
278 | 278 | * @return array Associative list of errors occured |
279 | 279 | */ |
280 | - protected function copyProducts( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey ) |
|
280 | + protected function copyProducts(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors, $localeKey) |
|
281 | 281 | { |
282 | - foreach( $basket->getProducts() as $pos => $product ) |
|
282 | + foreach ($basket->getProducts() as $pos => $product) |
|
283 | 283 | { |
284 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) { |
|
284 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) { |
|
285 | 285 | continue; |
286 | 286 | } |
287 | 287 | |
@@ -289,7 +289,7 @@ discard block |
||
289 | 289 | { |
290 | 290 | $attrIds = []; |
291 | 291 | |
292 | - foreach( $product->getAttributes() as $attrItem ) { |
|
292 | + foreach ($product->getAttributes() as $attrItem) { |
|
293 | 293 | $attrIds[$attrItem->getType()][] = $attrItem->getAttributeId(); |
294 | 294 | } |
295 | 295 | |
@@ -297,23 +297,23 @@ discard block |
||
297 | 297 | $product->getProductId(), |
298 | 298 | $product->getQuantity(), |
299 | 299 | [], |
300 | - $this->getValue( $attrIds, 'variant', [] ), |
|
301 | - $this->getValue( $attrIds, 'config', [] ), |
|
302 | - $this->getValue( $attrIds, 'hidden', [] ), |
|
303 | - $this->getValue( $attrIds, 'custom', [] ), |
|
300 | + $this->getValue($attrIds, 'variant', []), |
|
301 | + $this->getValue($attrIds, 'config', []), |
|
302 | + $this->getValue($attrIds, 'hidden', []), |
|
303 | + $this->getValue($attrIds, 'custom', []), |
|
304 | 304 | $product->getStockType() |
305 | 305 | ); |
306 | 306 | |
307 | - $basket->deleteProduct( $pos ); |
|
307 | + $basket->deleteProduct($pos); |
|
308 | 308 | } |
309 | - catch( \Exception $e ) |
|
309 | + catch (\Exception $e) |
|
310 | 310 | { |
311 | 311 | $code = $product->getProductCode(); |
312 | 312 | $logger = $this->getContext()->getLogger(); |
313 | 313 | $errors['product'][$pos] = $e->getMessage(); |
314 | 314 | |
315 | 315 | $str = 'Error migrating product with code "%1$s" in basket to locale "%2$s": %3$s'; |
316 | - $logger->log( sprintf( $str, $code, $localeKey, $e->getMessage() ), \Aimeos\MW\Logger\Base::INFO ); |
|
316 | + $logger->log(sprintf($str, $code, $localeKey, $e->getMessage()), \Aimeos\MW\Logger\Base::INFO); |
|
317 | 317 | } |
318 | 318 | } |
319 | 319 | |
@@ -328,22 +328,22 @@ discard block |
||
328 | 328 | * @param array $errors Associative list of previous errors |
329 | 329 | * @return array Associative list of errors occured |
330 | 330 | */ |
331 | - protected function copyServices( \Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors ) |
|
331 | + protected function copyServices(\Aimeos\MShop\Order\Item\Base\Iface $basket, array $errors) |
|
332 | 332 | { |
333 | - foreach( $basket->getServices() as $type => $item ) |
|
333 | + foreach ($basket->getServices() as $type => $item) |
|
334 | 334 | { |
335 | 335 | try |
336 | 336 | { |
337 | 337 | $attributes = []; |
338 | 338 | |
339 | - foreach( $item->getAttributes() as $attrItem ) { |
|
339 | + foreach ($item->getAttributes() as $attrItem) { |
|
340 | 340 | $attributes[$attrItem->getCode()] = $attrItem->getValue(); |
341 | 341 | } |
342 | 342 | |
343 | - $this->setService( $type, $item->getServiceId(), $attributes ); |
|
344 | - $basket->deleteService( $type ); |
|
343 | + $this->setService($type, $item->getServiceId(), $attributes); |
|
344 | + $basket->deleteService($type); |
|
345 | 345 | } |
346 | - catch( \Exception $e ) { ; } // Don't notify the user as appropriate services can be added automatically |
|
346 | + catch (\Exception $e) {; } // Don't notify the user as appropriate services can be added automatically |
|
347 | 347 | } |
348 | 348 | |
349 | 349 | return $errors; |
@@ -362,36 +362,36 @@ discard block |
||
362 | 362 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
363 | 363 | * @deprecated Use getOrderProductAttributes(), checkReferences() and calcPrice() instead |
364 | 364 | */ |
365 | - protected function createOrderProductAttributes( \Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
366 | - array $attributeIds, $type, array $attributeValues = [] ) |
|
365 | + protected function createOrderProductAttributes(\Aimeos\MShop\Price\Item\Iface $price, $prodid, $quantity, |
|
366 | + array $attributeIds, $type, array $attributeValues = []) |
|
367 | 367 | { |
368 | - if( empty( $attributeIds ) ) { |
|
368 | + if (empty($attributeIds)) { |
|
369 | 369 | return []; |
370 | 370 | } |
371 | 371 | |
372 | - $attrTypeId = $this->getProductListTypeItem( 'attribute', $type )->getId(); |
|
373 | - $this->checkReferences( $prodid, 'attribute', $attrTypeId, $attributeIds ); |
|
372 | + $attrTypeId = $this->getProductListTypeItem('attribute', $type)->getId(); |
|
373 | + $this->checkReferences($prodid, 'attribute', $attrTypeId, $attributeIds); |
|
374 | 374 | |
375 | 375 | $list = []; |
376 | 376 | $context = $this->getContext(); |
377 | 377 | |
378 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
379 | - $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product/attribute' ); |
|
378 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
379 | + $orderProductAttributeManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/product/attribute'); |
|
380 | 380 | |
381 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
381 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
382 | 382 | { |
383 | - $prices = $attrItem->getRefItems( 'price', 'default', 'default' ); |
|
383 | + $prices = $attrItem->getRefItems('price', 'default', 'default'); |
|
384 | 384 | |
385 | - if( !empty( $prices ) ) { |
|
386 | - $price->addItem( $priceManager->getLowestPrice( $prices, $quantity ) ); |
|
385 | + if (!empty($prices)) { |
|
386 | + $price->addItem($priceManager->getLowestPrice($prices, $quantity)); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | $item = $orderProductAttributeManager->createItem(); |
390 | - $item->copyFrom( $attrItem ); |
|
391 | - $item->setType( $type ); |
|
390 | + $item->copyFrom($attrItem); |
|
391 | + $item->setType($type); |
|
392 | 392 | |
393 | - if( isset( $attributeValues[$id] ) ) { |
|
394 | - $item->setValue( $attributeValues[$id] ); |
|
393 | + if (isset($attributeValues[$id])) { |
|
394 | + $item->setValue($attributeValues[$id]); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | $list[] = $item; |
@@ -409,31 +409,31 @@ discard block |
||
409 | 409 | * @return array List of items implementing \Aimeos\MShop\Attribute\Item\Iface |
410 | 410 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the actual attribute number doesn't match the expected one |
411 | 411 | */ |
412 | - protected function getAttributes( array $attributeIds, array $domains = array( 'price', 'text' ) ) |
|
412 | + protected function getAttributes(array $attributeIds, array $domains = array('price', 'text')) |
|
413 | 413 | { |
414 | - if( empty( $attributeIds ) ) { |
|
414 | + if (empty($attributeIds)) { |
|
415 | 415 | return []; |
416 | 416 | } |
417 | 417 | |
418 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
418 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
419 | 419 | |
420 | - $search = $attributeManager->createSearch( true ); |
|
420 | + $search = $attributeManager->createSearch(true); |
|
421 | 421 | $expr = array( |
422 | - $search->compare( '==', 'attribute.id', $attributeIds ), |
|
422 | + $search->compare('==', 'attribute.id', $attributeIds), |
|
423 | 423 | $search->getConditions(), |
424 | 424 | ); |
425 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
426 | - $search->setSlice( 0, 0x7fffffff ); |
|
425 | + $search->setConditions($search->combine('&&', $expr)); |
|
426 | + $search->setSlice(0, 0x7fffffff); |
|
427 | 427 | |
428 | - $attrItems = $attributeManager->searchItems( $search, $domains ); |
|
428 | + $attrItems = $attributeManager->searchItems($search, $domains); |
|
429 | 429 | |
430 | - if( count( $attrItems ) !== count( $attributeIds ) ) |
|
430 | + if (count($attrItems) !== count($attributeIds)) |
|
431 | 431 | { |
432 | - $expected = implode( ',', $attributeIds ); |
|
433 | - $actual = implode( ',', array_keys( $attrItems ) ); |
|
434 | - $msg = sprintf( 'Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected ); |
|
432 | + $expected = implode(',', $attributeIds); |
|
433 | + $actual = implode(',', array_keys($attrItems)); |
|
434 | + $msg = sprintf('Available attribute IDs "%1$s" do not match the given attribute IDs "%2$s"', $actual, $expected); |
|
435 | 435 | |
436 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
436 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $attrItems; |
@@ -446,31 +446,31 @@ discard block |
||
446 | 446 | * @param \Aimeos\MShop\Order\Item\Base\Product\Attribute\Item[] $orderAttributes List of order product attribute items |
447 | 447 | * @return \Aimeos\MShop\Attribute\Item\Iface[] Associative list of attribute IDs as key and attribute items as values |
448 | 448 | */ |
449 | - protected function getAttributeItems( array $orderAttributes ) |
|
449 | + protected function getAttributeItems(array $orderAttributes) |
|
450 | 450 | { |
451 | - if( empty( $orderAttributes ) ) { |
|
451 | + if (empty($orderAttributes)) { |
|
452 | 452 | return []; |
453 | 453 | } |
454 | 454 | |
455 | - $attributeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'attribute' ); |
|
456 | - $search = $attributeManager->createSearch( true ); |
|
455 | + $attributeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'attribute'); |
|
456 | + $search = $attributeManager->createSearch(true); |
|
457 | 457 | $expr = []; |
458 | 458 | |
459 | - foreach( $orderAttributes as $item ) |
|
459 | + foreach ($orderAttributes as $item) |
|
460 | 460 | { |
461 | 461 | $tmp = array( |
462 | - $search->compare( '==', 'attribute.domain', 'product' ), |
|
463 | - $search->compare( '==', 'attribute.code', $item->getValue() ), |
|
464 | - $search->compare( '==', 'attribute.type.domain', 'product' ), |
|
465 | - $search->compare( '==', 'attribute.type.code', $item->getCode() ), |
|
466 | - $search->compare( '>', 'attribute.type.status', 0 ), |
|
462 | + $search->compare('==', 'attribute.domain', 'product'), |
|
463 | + $search->compare('==', 'attribute.code', $item->getValue()), |
|
464 | + $search->compare('==', 'attribute.type.domain', 'product'), |
|
465 | + $search->compare('==', 'attribute.type.code', $item->getCode()), |
|
466 | + $search->compare('>', 'attribute.type.status', 0), |
|
467 | 467 | $search->getConditions(), |
468 | 468 | ); |
469 | - $expr[] = $search->combine( '&&', $tmp ); |
|
469 | + $expr[] = $search->combine('&&', $tmp); |
|
470 | 470 | } |
471 | 471 | |
472 | - $search->setConditions( $search->combine( '||', $expr ) ); |
|
473 | - return $attributeManager->searchItems( $search, array( 'price' ) ); |
|
472 | + $search->setConditions($search->combine('||', $expr)); |
|
473 | + return $attributeManager->searchItems($search, array('price')); |
|
474 | 474 | } |
475 | 475 | |
476 | 476 | |
@@ -485,23 +485,23 @@ discard block |
||
485 | 485 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
486 | 486 | * @deprecated Use getItem() or findItem() instead |
487 | 487 | */ |
488 | - protected function getDomainItem( $domain, $key, $value, array $ref ) |
|
488 | + protected function getDomainItem($domain, $key, $value, array $ref) |
|
489 | 489 | { |
490 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), $domain ); |
|
490 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), $domain); |
|
491 | 491 | |
492 | - $search = $manager->createSearch( true ); |
|
492 | + $search = $manager->createSearch(true); |
|
493 | 493 | $expr = array( |
494 | - $search->compare( '==', $key, $value ), |
|
494 | + $search->compare('==', $key, $value), |
|
495 | 495 | $search->getConditions(), |
496 | 496 | ); |
497 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
497 | + $search->setConditions($search->combine('&&', $expr)); |
|
498 | 498 | |
499 | - $result = $manager->searchItems( $search, $ref ); |
|
499 | + $result = $manager->searchItems($search, $ref); |
|
500 | 500 | |
501 | - if( ( $item = reset( $result ) ) === false ) |
|
501 | + if (($item = reset($result)) === false) |
|
502 | 502 | { |
503 | - $msg = sprintf( 'No item for "%1$s" (%2$s) found', $value, $key ); |
|
504 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
503 | + $msg = sprintf('No item for "%1$s" (%2$s) found', $value, $key); |
|
504 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | return $item; |
@@ -516,27 +516,27 @@ discard block |
||
516 | 516 | * @param array $attributeValues Associative list of attribute IDs as keys and their codes as values |
517 | 517 | * @return array List of items implementing \Aimeos\MShop\Order\Item\Product\Attribute\Iface |
518 | 518 | */ |
519 | - protected function getOrderProductAttributes( $type, array $attributeIds, array $attributeValues = [] ) |
|
519 | + protected function getOrderProductAttributes($type, array $attributeIds, array $attributeValues = []) |
|
520 | 520 | { |
521 | - if( empty( $attributeIds ) ) { |
|
521 | + if (empty($attributeIds)) { |
|
522 | 522 | return []; |
523 | 523 | } |
524 | 524 | |
525 | - foreach( $attributeValues as $key => $value ) { |
|
525 | + foreach ($attributeValues as $key => $value) { |
|
526 | 526 | $attributeValues[(string) $key] = $value; // Workaround for PHP bug #74739 |
527 | 527 | } |
528 | 528 | |
529 | 529 | $list = []; |
530 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product/attribute' ); |
|
530 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product/attribute'); |
|
531 | 531 | |
532 | - foreach( $this->getAttributes( $attributeIds ) as $id => $attrItem ) |
|
532 | + foreach ($this->getAttributes($attributeIds) as $id => $attrItem) |
|
533 | 533 | { |
534 | 534 | $item = $manager->createItem(); |
535 | - $item->copyFrom( $attrItem ); |
|
536 | - $item->setType( $type ); |
|
535 | + $item->copyFrom($attrItem); |
|
536 | + $item->setType($type); |
|
537 | 537 | |
538 | - if( isset( $attributeValues[$id] ) ) { |
|
539 | - $item->setValue( $attributeValues[$id] ); |
|
538 | + if (isset($attributeValues[$id])) { |
|
539 | + $item->setValue($attributeValues[$id]); |
|
540 | 540 | } |
541 | 541 | |
542 | 542 | $list[] = $item; |
@@ -553,21 +553,21 @@ discard block |
||
553 | 553 | * @param string $code Code of the list type |
554 | 554 | * @return \Aimeos\MShop\Common\Item\Type\Iface List type item |
555 | 555 | */ |
556 | - protected function getProductListTypeItem( $domain, $code ) |
|
556 | + protected function getProductListTypeItem($domain, $code) |
|
557 | 557 | { |
558 | - if( empty( $this->listTypeItems ) ) |
|
558 | + if (empty($this->listTypeItems)) |
|
559 | 559 | { |
560 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product/lists/type' ); |
|
560 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product/lists/type'); |
|
561 | 561 | |
562 | - foreach( $manager->searchItems( $manager->createSearch( true ) ) as $item ) { |
|
563 | - $this->listTypeItems[ $item->getDomain() ][ $item->getCode() ] = $item; |
|
562 | + foreach ($manager->searchItems($manager->createSearch(true)) as $item) { |
|
563 | + $this->listTypeItems[$item->getDomain()][$item->getCode()] = $item; |
|
564 | 564 | } |
565 | 565 | } |
566 | 566 | |
567 | - if( !isset( $this->listTypeItems[$domain][$code] ) ) |
|
567 | + if (!isset($this->listTypeItems[$domain][$code])) |
|
568 | 568 | { |
569 | - $msg = sprintf( 'List type for domain "%1$s" and code "%2$s" not found', $domain, $code ); |
|
570 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
569 | + $msg = sprintf('List type for domain "%1$s" and code "%2$s" not found', $domain, $code); |
|
570 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
571 | 571 | } |
572 | 572 | |
573 | 573 | return $this->listTypeItems[$domain][$code]; |
@@ -582,43 +582,43 @@ discard block |
||
582 | 582 | * @param array $domains Names of the domain items that should be fetched too |
583 | 583 | * @return array List of products matching the given attributes |
584 | 584 | */ |
585 | - protected function getProductVariants( \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
586 | - array $domains = array( 'attribute', 'media', 'price', 'text' ) ) |
|
585 | + protected function getProductVariants(\Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, |
|
586 | + array $domains = array('attribute', 'media', 'price', 'text')) |
|
587 | 587 | { |
588 | 588 | $subProductIds = []; |
589 | - foreach( $productItem->getRefItems( 'product', 'default', 'default' ) as $item ) { |
|
589 | + foreach ($productItem->getRefItems('product', 'default', 'default') as $item) { |
|
590 | 590 | $subProductIds[] = $item->getId(); |
591 | 591 | } |
592 | 592 | |
593 | - if( count( $subProductIds ) === 0 ) { |
|
593 | + if (count($subProductIds) === 0) { |
|
594 | 594 | return []; |
595 | 595 | } |
596 | 596 | |
597 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
598 | - $search = $productManager->createSearch( true ); |
|
597 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
598 | + $search = $productManager->createSearch(true); |
|
599 | 599 | |
600 | 600 | $expr = array( |
601 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
601 | + $search->compare('==', 'product.id', $subProductIds), |
|
602 | 602 | $search->getConditions(), |
603 | 603 | ); |
604 | 604 | |
605 | - if( count( $variantAttributeIds ) > 0 ) |
|
605 | + if (count($variantAttributeIds) > 0) |
|
606 | 606 | { |
607 | - foreach( $variantAttributeIds as $key => $id ) { |
|
607 | + foreach ($variantAttributeIds as $key => $id) { |
|
608 | 608 | $variantAttributeIds[$key] = (string) $id; |
609 | 609 | } |
610 | 610 | |
611 | - $listTypeItem = $this->getProductListTypeItem( 'attribute', 'variant' ); |
|
611 | + $listTypeItem = $this->getProductListTypeItem('attribute', 'variant'); |
|
612 | 612 | |
613 | - $param = array( 'attribute', $listTypeItem->getId(), $variantAttributeIds ); |
|
614 | - $cmpfunc = $search->createFunction( 'product.contains', $param ); |
|
613 | + $param = array('attribute', $listTypeItem->getId(), $variantAttributeIds); |
|
614 | + $cmpfunc = $search->createFunction('product.contains', $param); |
|
615 | 615 | |
616 | - $expr[] = $search->compare( '==', $cmpfunc, count( $variantAttributeIds ) ); |
|
616 | + $expr[] = $search->compare('==', $cmpfunc, count($variantAttributeIds)); |
|
617 | 617 | } |
618 | 618 | |
619 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
619 | + $search->setConditions($search->combine('&&', $expr)); |
|
620 | 620 | |
621 | - return $productManager->searchItems( $search, $domains ); |
|
621 | + return $productManager->searchItems($search, $domains); |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | |
@@ -630,9 +630,9 @@ discard block |
||
630 | 630 | * @param mixed $default Default value if no value is available for the given name |
631 | 631 | * @return mixed Value from the array or default value |
632 | 632 | */ |
633 | - protected function getValue( array $values, $name, $default = null ) |
|
633 | + protected function getValue(array $values, $name, $default = null) |
|
634 | 634 | { |
635 | - if( isset( $values[$name] ) ) { |
|
635 | + if (isset($values[$name])) { |
|
636 | 636 | return $values[$name]; |
637 | 637 | } |
638 | 638 |
@@ -21,46 +21,46 @@ discard block |
||
21 | 21 | |
22 | 22 | protected function tearDown() |
23 | 23 | { |
24 | - $this->context->getSession()->set( 'aimeos', [] ); |
|
24 | + $this->context->getSession()->set('aimeos', []); |
|
25 | 25 | |
26 | - unset( $this->context ); |
|
26 | + unset($this->context); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | |
30 | 30 | public function testCheckLocale() |
31 | 31 | { |
32 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
33 | - ->setConstructorArgs( [$this->context] ) |
|
34 | - ->setMethods( null ) |
|
32 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
33 | + ->setConstructorArgs([$this->context]) |
|
34 | + ->setMethods(null) |
|
35 | 35 | ->getMock(); |
36 | 36 | |
37 | - $this->context->getSession()->set( 'aimeos/basket/locale', 'unittest|en|EUR' ); |
|
38 | - $this->access( 'checkLocale' )->invokeArgs( $object, ['unittest'] ); |
|
37 | + $this->context->getSession()->set('aimeos/basket/locale', 'unittest|en|EUR'); |
|
38 | + $this->access('checkLocale')->invokeArgs($object, ['unittest']); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | |
42 | 42 | public function testCopyAddresses() |
43 | 43 | { |
44 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
44 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
45 | 45 | $ordBaseItem = $manager->createItem(); |
46 | 46 | |
47 | - $address = $this->getAddress( 'Example company' ); |
|
48 | - $ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
47 | + $address = $this->getAddress('Example company'); |
|
48 | + $ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
49 | 49 | |
50 | 50 | |
51 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
52 | - ->setConstructorArgs( [$this->context] ) |
|
53 | - ->setMethods( null ) |
|
51 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
52 | + ->setConstructorArgs([$this->context]) |
|
53 | + ->setMethods(null) |
|
54 | 54 | ->getMock(); |
55 | 55 | |
56 | - $result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
56 | + $result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
57 | 57 | |
58 | 58 | |
59 | - $this->assertEquals( ['test'], $result ); |
|
60 | - $this->assertEquals( 1, count( $object->get()->getAddresses() ) ); |
|
59 | + $this->assertEquals(['test'], $result); |
|
60 | + $this->assertEquals(1, count($object->get()->getAddresses())); |
|
61 | 61 | |
62 | - $addr = $object->get()->getAddress( \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
63 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr ); |
|
62 | + $addr = $object->get()->getAddress(\Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
63 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Address\Iface', $addr); |
|
64 | 64 | |
65 | 65 | $object->clear(); |
66 | 66 | } |
@@ -68,54 +68,54 @@ discard block |
||
68 | 68 | |
69 | 69 | public function testCopyAddressesException() |
70 | 70 | { |
71 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
71 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
72 | 72 | $ordBaseItem = $manager->createItem(); |
73 | 73 | |
74 | - $address = $this->getAddress( 'Example company' ); |
|
75 | - $ordBaseItem->setAddress( $address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT ); |
|
74 | + $address = $this->getAddress('Example company'); |
|
75 | + $ordBaseItem->setAddress($address, \Aimeos\MShop\Order\Item\Base\Address\Base::TYPE_PAYMENT); |
|
76 | 76 | |
77 | 77 | |
78 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
79 | - ->setConstructorArgs( [$this->context] ) |
|
80 | - ->setMethods( ['setAddress'] ) |
|
78 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
79 | + ->setConstructorArgs([$this->context]) |
|
80 | + ->setMethods(['setAddress']) |
|
81 | 81 | ->getMock(); |
82 | 82 | |
83 | - $object->expects( $this->once() )->method( 'setAddress' )->will( $this->throwException( new \Exception() ) ); |
|
83 | + $object->expects($this->once())->method('setAddress')->will($this->throwException(new \Exception())); |
|
84 | 84 | |
85 | - $result = $this->access( 'copyAddresses' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
85 | + $result = $this->access('copyAddresses')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
86 | 86 | |
87 | - $this->assertEquals( 1, count( $result ) ); |
|
88 | - $this->assertArrayHasKey( 'address', $result ); |
|
87 | + $this->assertEquals(1, count($result)); |
|
88 | + $this->assertArrayHasKey('address', $result); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | |
92 | 92 | public function testCopyCoupon() |
93 | 93 | { |
94 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
94 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
95 | 95 | $ordBaseItem = $manager->createItem(); |
96 | 96 | |
97 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC', ['price'] ); |
|
98 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
99 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
97 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC', ['price']); |
|
98 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
99 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
100 | 100 | |
101 | - $priceItems = $product->getRefItems( 'price' ); |
|
102 | - $ordProdItem->setPrice( reset( $priceItems ) ); |
|
101 | + $priceItems = $product->getRefItems('price'); |
|
102 | + $ordProdItem->setPrice(reset($priceItems)); |
|
103 | 103 | |
104 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
105 | - $ordBaseItem->addCoupon( 'OPQR', [] ); |
|
104 | + $ordBaseItem->addProduct($ordProdItem); |
|
105 | + $ordBaseItem->addCoupon('OPQR', []); |
|
106 | 106 | |
107 | 107 | |
108 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
109 | - ->setConstructorArgs( [$this->context] ) |
|
110 | - ->setMethods( null ) |
|
108 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
109 | + ->setConstructorArgs([$this->context]) |
|
110 | + ->setMethods(null) |
|
111 | 111 | ->getMock(); |
112 | 112 | |
113 | - $object->addProduct( $product->getId() ); |
|
113 | + $object->addProduct($product->getId()); |
|
114 | 114 | |
115 | - $result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
115 | + $result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
116 | 116 | |
117 | 117 | |
118 | - $this->assertEquals( ['test'], $result ); |
|
118 | + $this->assertEquals(['test'], $result); |
|
119 | 119 | |
120 | 120 | $object->clear(); |
121 | 121 | } |
@@ -123,48 +123,48 @@ discard block |
||
123 | 123 | |
124 | 124 | public function testCopyCouponException() |
125 | 125 | { |
126 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
126 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
127 | 127 | $ordBaseItem = $manager->createItem(); |
128 | 128 | |
129 | - $ordBaseItem->addCoupon( '90AB', [] ); |
|
129 | + $ordBaseItem->addCoupon('90AB', []); |
|
130 | 130 | |
131 | 131 | |
132 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
133 | - ->setConstructorArgs( [$this->context] ) |
|
134 | - ->setMethods( ['addCoupon'] ) |
|
132 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
133 | + ->setConstructorArgs([$this->context]) |
|
134 | + ->setMethods(['addCoupon']) |
|
135 | 135 | ->getMock(); |
136 | 136 | |
137 | - $object->expects( $this->once() )->method( 'addCoupon' )->will( $this->throwException( new \Exception() ) ); |
|
137 | + $object->expects($this->once())->method('addCoupon')->will($this->throwException(new \Exception())); |
|
138 | 138 | |
139 | - $result = $this->access( 'copyCoupons' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
139 | + $result = $this->access('copyCoupons')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
140 | 140 | |
141 | - $this->assertEquals( 1, count( $result ) ); |
|
142 | - $this->assertArrayHasKey( 'coupon', $result ); |
|
141 | + $this->assertEquals(1, count($result)); |
|
142 | + $this->assertArrayHasKey('coupon', $result); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
146 | 146 | public function testCopyProduct() |
147 | 147 | { |
148 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
148 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
149 | 149 | $ordBaseItem = $manager->createItem(); |
150 | 150 | |
151 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
152 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
153 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
154 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
151 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
152 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
153 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
154 | + $ordBaseItem->addProduct($ordProdItem); |
|
155 | 155 | |
156 | 156 | |
157 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
158 | - ->setConstructorArgs( [$this->context] ) |
|
159 | - ->setMethods( null ) |
|
157 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
158 | + ->setConstructorArgs([$this->context]) |
|
159 | + ->setMethods(null) |
|
160 | 160 | ->getMock(); |
161 | 161 | |
162 | - $result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
162 | + $result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
163 | 163 | |
164 | 164 | |
165 | - $this->assertEquals( ['test'], $result ); |
|
166 | - $this->assertEquals( 1, count( $object->get()->getProducts() ) ); |
|
167 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct( 0 ) ); |
|
165 | + $this->assertEquals(['test'], $result); |
|
166 | + $this->assertEquals(1, count($object->get()->getProducts())); |
|
167 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Product\Iface', $object->get()->getProduct(0)); |
|
168 | 168 | |
169 | 169 | $object->clear(); |
170 | 170 | } |
@@ -172,56 +172,56 @@ discard block |
||
172 | 172 | |
173 | 173 | public function testCopyProductException() |
174 | 174 | { |
175 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
175 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
176 | 176 | $ordBaseItem = $manager->createItem(); |
177 | 177 | |
178 | - $product = \Aimeos\MShop\Factory::createManager( $this->context, 'product' )->findItem( 'CNC' ); |
|
179 | - $ordProdManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/product' ); |
|
180 | - $ordProdItem = $ordProdManager->createItem()->copyFrom( $product ); |
|
181 | - $ordBaseItem->addProduct( $ordProdItem ); |
|
178 | + $product = \Aimeos\MShop\Factory::createManager($this->context, 'product')->findItem('CNC'); |
|
179 | + $ordProdManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/product'); |
|
180 | + $ordProdItem = $ordProdManager->createItem()->copyFrom($product); |
|
181 | + $ordBaseItem->addProduct($ordProdItem); |
|
182 | 182 | |
183 | 183 | |
184 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
185 | - ->setConstructorArgs( [$this->context] ) |
|
186 | - ->setMethods( ['addProduct'] ) |
|
184 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
185 | + ->setConstructorArgs([$this->context]) |
|
186 | + ->setMethods(['addProduct']) |
|
187 | 187 | ->getMock(); |
188 | 188 | |
189 | - $object->expects( $this->once() )->method( 'addProduct' )->will( $this->throwException( new \Exception() ) ); |
|
189 | + $object->expects($this->once())->method('addProduct')->will($this->throwException(new \Exception())); |
|
190 | 190 | |
191 | - $result = $this->access( 'copyProducts' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
191 | + $result = $this->access('copyProducts')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
192 | 192 | |
193 | - $this->assertEquals( 1, count( $result ) ); |
|
194 | - $this->assertArrayHasKey( 'product', $result ); |
|
193 | + $this->assertEquals(1, count($result)); |
|
194 | + $this->assertArrayHasKey('product', $result); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | |
198 | 198 | public function testCopyServices() |
199 | 199 | { |
200 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
200 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
201 | 201 | $ordBaseItem = $manager->createItem(); |
202 | 202 | |
203 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
204 | - $ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' ); |
|
203 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
204 | + $ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service'); |
|
205 | 205 | |
206 | - $serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
207 | - $ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem ); |
|
206 | + $serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery'); |
|
207 | + $ordServItem = $ordServManager->createItem()->copyFrom($serviceItem); |
|
208 | 208 | |
209 | - $ordBaseItem->setService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
209 | + $ordBaseItem->setService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
210 | 210 | |
211 | 211 | |
212 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
213 | - ->setConstructorArgs( [$this->context] ) |
|
214 | - ->setMethods( null ) |
|
212 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
213 | + ->setConstructorArgs([$this->context]) |
|
214 | + ->setMethods(null) |
|
215 | 215 | ->getMock(); |
216 | 216 | |
217 | - $result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, ['test'], 'unittest|en|EUR'] ); |
|
217 | + $result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, ['test'], 'unittest|en|EUR']); |
|
218 | 218 | |
219 | 219 | |
220 | - $this->assertEquals( ['test'], $result ); |
|
221 | - $this->assertEquals( 1, count( $object->get()->getServices() ) ); |
|
220 | + $this->assertEquals(['test'], $result); |
|
221 | + $this->assertEquals(1, count($object->get()->getServices())); |
|
222 | 222 | |
223 | - $service = $object->get()->getService( \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
224 | - $this->assertInstanceOf( '\Aimeos\MShop\Order\Item\Base\Service\Iface', $service ); |
|
223 | + $service = $object->get()->getService(\Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
224 | + $this->assertInstanceOf('\Aimeos\MShop\Order\Item\Base\Service\Iface', $service); |
|
225 | 225 | |
226 | 226 | $object->clear(); |
227 | 227 | } |
@@ -229,77 +229,77 @@ discard block |
||
229 | 229 | |
230 | 230 | public function testCopyServicesException() |
231 | 231 | { |
232 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base' ); |
|
232 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base'); |
|
233 | 233 | $ordBaseItem = $manager->createItem(); |
234 | 234 | |
235 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $this->context, 'service' ); |
|
236 | - $ordServManager = \Aimeos\MShop\Factory::createManager( $this->context, 'order/base/service' ); |
|
235 | + $serviceManager = \Aimeos\MShop\Factory::createManager($this->context, 'service'); |
|
236 | + $ordServManager = \Aimeos\MShop\Factory::createManager($this->context, 'order/base/service'); |
|
237 | 237 | |
238 | - $serviceItem = $serviceManager->findItem( 'unitcode', [], 'service', 'delivery' ); |
|
239 | - $ordServItem = $ordServManager->createItem()->copyFrom( $serviceItem ); |
|
238 | + $serviceItem = $serviceManager->findItem('unitcode', [], 'service', 'delivery'); |
|
239 | + $ordServItem = $ordServManager->createItem()->copyFrom($serviceItem); |
|
240 | 240 | |
241 | - $ordBaseItem->setService( $ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY ); |
|
241 | + $ordBaseItem->setService($ordServItem, \Aimeos\MShop\Order\Item\Base\Service\Base::TYPE_DELIVERY); |
|
242 | 242 | |
243 | 243 | |
244 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
245 | - ->setConstructorArgs( [$this->context] ) |
|
246 | - ->setMethods( ['setService'] ) |
|
244 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
245 | + ->setConstructorArgs([$this->context]) |
|
246 | + ->setMethods(['setService']) |
|
247 | 247 | ->getMock(); |
248 | 248 | |
249 | - $object->expects( $this->once() )->method( 'setService' )->will( $this->throwException( new \Exception() ) ); |
|
249 | + $object->expects($this->once())->method('setService')->will($this->throwException(new \Exception())); |
|
250 | 250 | |
251 | - $result = $this->access( 'copyServices' )->invokeArgs( $object, [$ordBaseItem, [], 'unittest|en|EUR'] ); |
|
251 | + $result = $this->access('copyServices')->invokeArgs($object, [$ordBaseItem, [], 'unittest|en|EUR']); |
|
252 | 252 | |
253 | - $this->assertEquals( 0, count( $result ) ); |
|
253 | + $this->assertEquals(0, count($result)); |
|
254 | 254 | } |
255 | 255 | |
256 | 256 | |
257 | 257 | public function testGetOrderProductAttributes() |
258 | 258 | { |
259 | - $object = $this->getMockBuilder( '\Aimeos\Controller\Frontend\Basket\Standard' ) |
|
260 | - ->setConstructorArgs( [$this->context] ) |
|
261 | - ->setMethods( ['getAttributes'] ) |
|
259 | + $object = $this->getMockBuilder('\Aimeos\Controller\Frontend\Basket\Standard') |
|
260 | + ->setConstructorArgs([$this->context]) |
|
261 | + ->setMethods(['getAttributes']) |
|
262 | 262 | ->getMock(); |
263 | 263 | |
264 | - $list = [1 => new \Aimeos\MShop\Attribute\Item\Standard( ['attribute.code' => 'special_instructions'] )]; |
|
265 | - $object->expects( $this->once() )->method( 'getAttributes' )->will( $this->returnValue( $list ) ); |
|
264 | + $list = [1 => new \Aimeos\MShop\Attribute\Item\Standard(['attribute.code' => 'special_instructions'])]; |
|
265 | + $object->expects($this->once())->method('getAttributes')->will($this->returnValue($list)); |
|
266 | 266 | |
267 | 267 | $values = new \stdClass(); // test for PHP bug |
268 | 268 | $values->{'1'} = 'test'; |
269 | - $result = $this->access( 'getOrderProductAttributes' )->invokeArgs( $object, ['test', ['1'], (array) $values] ); |
|
269 | + $result = $this->access('getOrderProductAttributes')->invokeArgs($object, ['test', ['1'], (array) $values]); |
|
270 | 270 | |
271 | - $this->assertEquals( 1, count( $result ) ); |
|
272 | - $this->assertEquals( 'test', $result[0]->getValue() ); |
|
271 | + $this->assertEquals(1, count($result)); |
|
272 | + $this->assertEquals('test', $result[0]->getValue()); |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
276 | 276 | /** |
277 | 277 | * @param string $company |
278 | 278 | */ |
279 | - protected function getAddress( $company ) |
|
279 | + protected function getAddress($company) |
|
280 | 280 | { |
281 | - $manager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'customer/address' ); |
|
281 | + $manager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'customer/address'); |
|
282 | 282 | |
283 | 283 | $search = $manager->createSearch(); |
284 | - $search->setConditions( $search->compare( '==', 'customer.address.company', $company ) ); |
|
285 | - $items = $manager->searchItems( $search ); |
|
284 | + $search->setConditions($search->compare('==', 'customer.address.company', $company)); |
|
285 | + $items = $manager->searchItems($search); |
|
286 | 286 | |
287 | - if( ( $item = reset( $items ) ) === false ) { |
|
288 | - throw new \RuntimeException( sprintf( 'No address item with company "%1$s" found', $company ) ); |
|
287 | + if (($item = reset($items)) === false) { |
|
288 | + throw new \RuntimeException(sprintf('No address item with company "%1$s" found', $company)); |
|
289 | 289 | } |
290 | 290 | |
291 | - $ordAddrManager = \Aimeos\MShop\Factory::createManager( \TestHelperFrontend::getContext(), 'order/base/address' ); |
|
292 | - $ordAddrItem = $ordAddrManager->createItem()->copyFrom( $item ); |
|
291 | + $ordAddrManager = \Aimeos\MShop\Factory::createManager(\TestHelperFrontend::getContext(), 'order/base/address'); |
|
292 | + $ordAddrItem = $ordAddrManager->createItem()->copyFrom($item); |
|
293 | 293 | |
294 | 294 | return $ordAddrItem; |
295 | 295 | } |
296 | 296 | |
297 | 297 | |
298 | - protected function access( $name ) |
|
298 | + protected function access($name) |
|
299 | 299 | { |
300 | - $class = new \ReflectionClass( '\Aimeos\Controller\Frontend\Basket\Base' ); |
|
301 | - $method = $class->getMethod( $name ); |
|
302 | - $method->setAccessible( true ); |
|
300 | + $class = new \ReflectionClass('\Aimeos\Controller\Frontend\Basket\Base'); |
|
301 | + $method = $class->getMethod($name); |
|
302 | + $method->setAccessible(true); |
|
303 | 303 | |
304 | 304 | return $method; |
305 | 305 | } |
@@ -33,11 +33,11 @@ discard block |
||
33 | 33 | * @param \Aimeos\MShop\Context\Item\Iface $context Object storing the required instances for manaing databases |
34 | 34 | * connections, logger, session, etc. |
35 | 35 | */ |
36 | - public function __construct( \Aimeos\MShop\Context\Item\Iface $context ) |
|
36 | + public function __construct(\Aimeos\MShop\Context\Item\Iface $context) |
|
37 | 37 | { |
38 | - parent::__construct( $context ); |
|
38 | + parent::__construct($context); |
|
39 | 39 | |
40 | - $this->domainManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base' ); |
|
40 | + $this->domainManager = \Aimeos\MShop\Factory::createManager($context, 'order/base'); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function clear() |
50 | 50 | { |
51 | 51 | $this->baskets[$this->type] = $this->domainManager->createItem(); |
52 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
52 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
53 | 53 | |
54 | 54 | return $this; |
55 | 55 | } |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | */ |
63 | 63 | public function get() |
64 | 64 | { |
65 | - if( !isset( $this->baskets[$this->type] ) ) |
|
65 | + if (!isset($this->baskets[$this->type])) |
|
66 | 66 | { |
67 | - $this->baskets[$this->type] = $this->domainManager->getSession( $this->type ); |
|
68 | - $this->checkLocale( $this->type ); |
|
67 | + $this->baskets[$this->type] = $this->domainManager->getSession($this->type); |
|
68 | + $this->checkLocale($this->type); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | return $this->baskets[$this->type]; |
@@ -79,8 +79,8 @@ discard block |
||
79 | 79 | */ |
80 | 80 | public function save() |
81 | 81 | { |
82 | - if( isset( $this->baskets[$this->type] ) && $this->baskets[$this->type]->isModified() ) { |
|
83 | - $this->domainManager->setSession( $this->baskets[$this->type], $this->type ); |
|
82 | + if (isset($this->baskets[$this->type]) && $this->baskets[$this->type]->isModified()) { |
|
83 | + $this->domainManager->setSession($this->baskets[$this->type], $this->type); |
|
84 | 84 | } |
85 | 85 | |
86 | 86 | return $this; |
@@ -93,7 +93,7 @@ discard block |
||
93 | 93 | * @param string $type Basket type |
94 | 94 | * @return \Aimeos\Controller\Frontend\Basket\Iface Basket frontend object |
95 | 95 | */ |
96 | - public function setType( $type ) |
|
96 | + public function setType($type) |
|
97 | 97 | { |
98 | 98 | $this->type = $type; |
99 | 99 | return $this; |
@@ -127,7 +127,7 @@ discard block |
||
127 | 127 | * @category Developer |
128 | 128 | * @see controller/frontend/basket/limit-seconds |
129 | 129 | */ |
130 | - $count = $config->get( 'controller/frontend/basket/limit-count', 5 ); |
|
130 | + $count = $config->get('controller/frontend/basket/limit-count', 5); |
|
131 | 131 | |
132 | 132 | /** controller/frontend/basket/limit-seconds |
133 | 133 | * Order limitation time frame in seconds |
@@ -145,28 +145,28 @@ discard block |
||
145 | 145 | * @category Developer |
146 | 146 | * @see controller/frontend/basket/limit-count |
147 | 147 | */ |
148 | - $seconds = $config->get( 'controller/frontend/basket/limit-seconds', 300 ); |
|
148 | + $seconds = $config->get('controller/frontend/basket/limit-seconds', 300); |
|
149 | 149 | |
150 | 150 | $search = $this->domainManager->createSearch(); |
151 | 151 | $expr = [ |
152 | - $search->compare( '==', 'order.base.editor', $context->getEditor() ), |
|
153 | - $search->compare( '>=', 'order.base.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
152 | + $search->compare('==', 'order.base.editor', $context->getEditor()), |
|
153 | + $search->compare('>=', 'order.base.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
154 | 154 | ]; |
155 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
156 | - $search->setSlice( 0, 0 ); |
|
155 | + $search->setConditions($search->combine('&&', $expr)); |
|
156 | + $search->setSlice(0, 0); |
|
157 | 157 | |
158 | - $this->domainManager->searchItems( $search, [], $total ); |
|
158 | + $this->domainManager->searchItems($search, [], $total); |
|
159 | 159 | |
160 | - if( $total > $count ) { |
|
161 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary order limit reached' ) ); |
|
160 | + if ($total > $count) { |
|
161 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary order limit reached')); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
165 | 165 | $basket = $this->get()->finish(); |
166 | - $basket->setCustomerId( (string) $context->getUserId() ); |
|
166 | + $basket->setCustomerId((string) $context->getUserId()); |
|
167 | 167 | |
168 | 168 | $this->domainManager->begin(); |
169 | - $this->domainManager->store( $basket ); |
|
169 | + $this->domainManager->store($basket); |
|
170 | 170 | $this->domainManager->commit(); |
171 | 171 | |
172 | 172 | return $basket; |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * @param boolean $default True to add default criteria (user logged in), false if not |
182 | 182 | * @return \Aimeos\MShop\Order\Item\Base\Iface Order base object including the given parts |
183 | 183 | */ |
184 | - public function load( $id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true ) |
|
184 | + public function load($id, $parts = \Aimeos\MShop\Order\Manager\Base\Base::PARTS_ALL, $default = true) |
|
185 | 185 | { |
186 | - return $this->domainManager->load( $id, $parts, false, $default ); |
|
186 | + return $this->domainManager->load($id, $parts, false, $default); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -203,34 +203,34 @@ discard block |
||
203 | 203 | * @param string $stocktype Unique code of the stock type to deliver the products from |
204 | 204 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
205 | 205 | */ |
206 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
206 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
207 | 207 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
208 | - $stocktype = 'default' ) |
|
208 | + $stocktype = 'default') |
|
209 | 209 | { |
210 | 210 | $attributeMap = [ |
211 | - 'custom' => array_keys( $customAttributeValues ), |
|
211 | + 'custom' => array_keys($customAttributeValues), |
|
212 | 212 | 'config' => $configAttributeIds, |
213 | 213 | 'hidden' => $hiddenAttributeIds, |
214 | 214 | ]; |
215 | - $this->checkListRef( $prodid, 'attribute', $attributeMap ); |
|
215 | + $this->checkListRef($prodid, 'attribute', $attributeMap); |
|
216 | 216 | |
217 | 217 | |
218 | 218 | $context = $this->getContext(); |
219 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
220 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
221 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
219 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
220 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
221 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
222 | 222 | |
223 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
224 | - $orderBaseProductItem->copyFrom( $productItem )->setQuantity( $quantity )->setStockType( $stocktype ); |
|
223 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
224 | + $orderBaseProductItem->copyFrom($productItem)->setQuantity($quantity)->setStockType($stocktype); |
|
225 | 225 | |
226 | - $attr = $this->getOrderProductAttributes( 'custom', array_keys( $customAttributeValues ), $customAttributeValues ); |
|
227 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'config', $configAttributeIds ) ); |
|
228 | - $attr = array_merge( $attr, $this->getOrderProductAttributes( 'hidden', $hiddenAttributeIds ) ); |
|
226 | + $attr = $this->getOrderProductAttributes('custom', array_keys($customAttributeValues), $customAttributeValues); |
|
227 | + $attr = array_merge($attr, $this->getOrderProductAttributes('config', $configAttributeIds)); |
|
228 | + $attr = array_merge($attr, $this->getOrderProductAttributes('hidden', $hiddenAttributeIds)); |
|
229 | 229 | |
230 | - $orderBaseProductItem->setAttributes( $attr ); |
|
231 | - $orderBaseProductItem->setPrice( $this->calcPrice( $orderBaseProductItem, $prices, $quantity ) ); |
|
230 | + $orderBaseProductItem->setAttributes($attr); |
|
231 | + $orderBaseProductItem->setPrice($this->calcPrice($orderBaseProductItem, $prices, $quantity)); |
|
232 | 232 | |
233 | - $this->get()->addProduct( $orderBaseProductItem ); |
|
233 | + $this->get()->addProduct($orderBaseProductItem); |
|
234 | 234 | $this->save(); |
235 | 235 | } |
236 | 236 | |
@@ -240,17 +240,17 @@ discard block |
||
240 | 240 | * |
241 | 241 | * @param integer $position Position number (key) of the order product item |
242 | 242 | */ |
243 | - public function deleteProduct( $position ) |
|
243 | + public function deleteProduct($position) |
|
244 | 244 | { |
245 | - $product = $this->get()->getProduct( $position ); |
|
245 | + $product = $this->get()->getProduct($position); |
|
246 | 246 | |
247 | - if( $product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
247 | + if ($product->getFlags() === \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
248 | 248 | { |
249 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be deleted manually', $position ); |
|
250 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
249 | + $msg = sprintf('Basket item at position "%1$d" cannot be deleted manually', $position); |
|
250 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
251 | 251 | } |
252 | 252 | |
253 | - $this->get()->deleteProduct( $position ); |
|
253 | + $this->get()->deleteProduct($position); |
|
254 | 254 | $this->save(); |
255 | 255 | } |
256 | 256 | |
@@ -264,33 +264,33 @@ discard block |
||
264 | 264 | * The 'stock'=>false option allows adding products without being in stock. |
265 | 265 | * @param string[] $configAttributeCodes Codes of the product config attributes that should be REMOVED |
266 | 266 | */ |
267 | - public function editProduct( $position, $quantity, array $options = [], |
|
268 | - array $configAttributeCodes = [] ) |
|
267 | + public function editProduct($position, $quantity, array $options = [], |
|
268 | + array $configAttributeCodes = []) |
|
269 | 269 | { |
270 | - $product = $this->get()->getProduct( $position ); |
|
270 | + $product = $this->get()->getProduct($position); |
|
271 | 271 | |
272 | - if( $product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE ) |
|
272 | + if ($product->getFlags() & \Aimeos\MShop\Order\Item\Base\Product\Base::FLAG_IMMUTABLE) |
|
273 | 273 | { |
274 | - $msg = sprintf( 'Basket item at position "%1$d" cannot be changed', $position ); |
|
275 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
274 | + $msg = sprintf('Basket item at position "%1$d" cannot be changed', $position); |
|
275 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
276 | 276 | } |
277 | 277 | |
278 | - $product->setQuantity( $quantity ); |
|
278 | + $product->setQuantity($quantity); |
|
279 | 279 | |
280 | 280 | $attributes = $product->getAttributes(); |
281 | - foreach( $attributes as $key => $attribute ) |
|
281 | + foreach ($attributes as $key => $attribute) |
|
282 | 282 | { |
283 | - if( in_array( $attribute->getCode(), $configAttributeCodes ) ) { |
|
284 | - unset( $attributes[$key] ); |
|
283 | + if (in_array($attribute->getCode(), $configAttributeCodes)) { |
|
284 | + unset($attributes[$key]); |
|
285 | 285 | } |
286 | 286 | } |
287 | - $product->setAttributes( $attributes ); |
|
287 | + $product->setAttributes($attributes); |
|
288 | 288 | |
289 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
290 | - $productItem = $manager->findItem( $product->getProductCode(), array( 'price', 'text' ) ); |
|
291 | - $product->setPrice( $this->calcPrice( $product, $productItem->getRefItems( 'price', 'default' ), $quantity ) ); |
|
289 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
290 | + $productItem = $manager->findItem($product->getProductCode(), array('price', 'text')); |
|
291 | + $product->setPrice($this->calcPrice($product, $productItem->getRefItems('price', 'default'), $quantity)); |
|
292 | 292 | |
293 | - $this->get()->editProduct( $product, $position ); |
|
293 | + $this->get()->editProduct($product, $position); |
|
294 | 294 | |
295 | 295 | $this->save(); |
296 | 296 | } |
@@ -302,49 +302,49 @@ discard block |
||
302 | 302 | * @param string $code Coupon code entered by the user |
303 | 303 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid or not allowed |
304 | 304 | */ |
305 | - public function addCoupon( $code ) |
|
305 | + public function addCoupon($code) |
|
306 | 306 | { |
307 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
308 | - $codeManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon/code' ); |
|
307 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
308 | + $codeManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon/code'); |
|
309 | 309 | |
310 | 310 | |
311 | - $search = $codeManager->createSearch( true ); |
|
311 | + $search = $codeManager->createSearch(true); |
|
312 | 312 | $expr = array( |
313 | - $search->compare( '==', 'coupon.code.code', $code ), |
|
313 | + $search->compare('==', 'coupon.code.code', $code), |
|
314 | 314 | $search->getConditions(), |
315 | 315 | ); |
316 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
317 | - $search->setSlice( 0, 1 ); |
|
316 | + $search->setConditions($search->combine('&&', $expr)); |
|
317 | + $search->setSlice(0, 1); |
|
318 | 318 | |
319 | - $result = $codeManager->searchItems( $search ); |
|
319 | + $result = $codeManager->searchItems($search); |
|
320 | 320 | |
321 | - if( ( $codeItem = reset( $result ) ) === false ) { |
|
322 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid or not available any more', $code ) ); |
|
321 | + if (($codeItem = reset($result)) === false) { |
|
322 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid or not available any more', $code)); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | |
326 | - $search = $manager->createSearch( true ); |
|
326 | + $search = $manager->createSearch(true); |
|
327 | 327 | $expr = array( |
328 | - $search->compare( '==', 'coupon.id', $codeItem->getParentId() ), |
|
328 | + $search->compare('==', 'coupon.id', $codeItem->getParentId()), |
|
329 | 329 | $search->getConditions(), |
330 | 330 | ); |
331 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
332 | - $search->setSlice( 0, 1 ); |
|
331 | + $search->setConditions($search->combine('&&', $expr)); |
|
332 | + $search->setSlice(0, 1); |
|
333 | 333 | |
334 | - $result = $manager->searchItems( $search ); |
|
334 | + $result = $manager->searchItems($search); |
|
335 | 335 | |
336 | - if( ( $item = reset( $result ) ) === false ) { |
|
337 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon for code "%1$s" is not available any more', $code ) ); |
|
336 | + if (($item = reset($result)) === false) { |
|
337 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon for code "%1$s" is not available any more', $code)); |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | |
341 | - $provider = $manager->getProvider( $item, $code ); |
|
341 | + $provider = $manager->getProvider($item, $code); |
|
342 | 342 | |
343 | - if( $provider->isAvailable( $this->get() ) !== true ) { |
|
344 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Requirements for coupon code "%1$s" aren\'t met', $code ) ); |
|
343 | + if ($provider->isAvailable($this->get()) !== true) { |
|
344 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Requirements for coupon code "%1$s" aren\'t met', $code)); |
|
345 | 345 | } |
346 | 346 | |
347 | - $provider->addCoupon( $this->get() ); |
|
347 | + $provider->addCoupon($this->get()); |
|
348 | 348 | $this->save(); |
349 | 349 | } |
350 | 350 | |
@@ -355,21 +355,21 @@ discard block |
||
355 | 355 | * @param string $code Coupon code entered by the user |
356 | 356 | * @throws \Aimeos\Controller\Frontend\Basket\Exception if the coupon code is invalid |
357 | 357 | */ |
358 | - public function deleteCoupon( $code ) |
|
358 | + public function deleteCoupon($code) |
|
359 | 359 | { |
360 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'coupon' ); |
|
360 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'coupon'); |
|
361 | 361 | |
362 | 362 | $search = $manager->createSearch(); |
363 | - $search->setConditions( $search->compare( '==', 'coupon.code.code', $code ) ); |
|
364 | - $search->setSlice( 0, 1 ); |
|
363 | + $search->setConditions($search->compare('==', 'coupon.code.code', $code)); |
|
364 | + $search->setSlice(0, 1); |
|
365 | 365 | |
366 | - $result = $manager->searchItems( $search ); |
|
366 | + $result = $manager->searchItems($search); |
|
367 | 367 | |
368 | - if( ( $item = reset( $result ) ) === false ) { |
|
369 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Coupon code "%1$s" is invalid', $code ) ); |
|
368 | + if (($item = reset($result)) === false) { |
|
369 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Coupon code "%1$s" is invalid', $code)); |
|
370 | 370 | } |
371 | 371 | |
372 | - $manager->getProvider( $item, $code )->deleteCoupon( $this->get() ); |
|
372 | + $manager->getProvider($item, $code)->deleteCoupon($this->get()); |
|
373 | 373 | $this->save(); |
374 | 374 | } |
375 | 375 | |
@@ -382,28 +382,28 @@ discard block |
||
382 | 382 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the billing or delivery address is not of any required type of |
383 | 383 | * if one of the keys is invalid when using an array with key/value pairs |
384 | 384 | */ |
385 | - public function setAddress( $type, $value ) |
|
385 | + public function setAddress($type, $value) |
|
386 | 386 | { |
387 | - $address = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/address' )->createItem(); |
|
388 | - $address->setType( $type ); |
|
387 | + $address = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/address')->createItem(); |
|
388 | + $address->setType($type); |
|
389 | 389 | |
390 | - if( $value instanceof \Aimeos\MShop\Common\Item\Address\Iface ) |
|
390 | + if ($value instanceof \Aimeos\MShop\Common\Item\Address\Iface) |
|
391 | 391 | { |
392 | - $address->copyFrom( $value ); |
|
393 | - $this->get()->setAddress( $address, $type ); |
|
392 | + $address->copyFrom($value); |
|
393 | + $this->get()->setAddress($address, $type); |
|
394 | 394 | } |
395 | - else if( is_array( $value ) ) |
|
395 | + else if (is_array($value)) |
|
396 | 396 | { |
397 | - $this->setAddressFromArray( $address, $value ); |
|
398 | - $this->get()->setAddress( $address, $type ); |
|
397 | + $this->setAddressFromArray($address, $value); |
|
398 | + $this->get()->setAddress($address, $type); |
|
399 | 399 | } |
400 | - else if( $value === null ) |
|
400 | + else if ($value === null) |
|
401 | 401 | { |
402 | - $this->get()->deleteAddress( $type ); |
|
402 | + $this->get()->deleteAddress($type); |
|
403 | 403 | } |
404 | 404 | else |
405 | 405 | { |
406 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Invalid value for address type "%1$s"', $type ) ); |
|
406 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Invalid value for address type "%1$s"', $type)); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | $this->save(); |
@@ -419,48 +419,48 @@ discard block |
||
419 | 419 | * entered by the customer when choosing one of the delivery or payment options |
420 | 420 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If there is no price to the service item attached |
421 | 421 | */ |
422 | - public function setService( $type, $id, array $attributes = [] ) |
|
422 | + public function setService($type, $id, array $attributes = []) |
|
423 | 423 | { |
424 | - if( $id === null ) |
|
424 | + if ($id === null) |
|
425 | 425 | { |
426 | - $this->get()->deleteService( $type ); |
|
426 | + $this->get()->deleteService($type); |
|
427 | 427 | $this->save(); |
428 | 428 | return; |
429 | 429 | } |
430 | 430 | |
431 | 431 | $context = $this->getContext(); |
432 | 432 | |
433 | - $serviceManager = \Aimeos\MShop\Factory::createManager( $context, 'service' ); |
|
434 | - $serviceItem = $serviceManager->getItem( $id, array( 'media', 'price', 'text' ) ); |
|
433 | + $serviceManager = \Aimeos\MShop\Factory::createManager($context, 'service'); |
|
434 | + $serviceItem = $serviceManager->getItem($id, array('media', 'price', 'text')); |
|
435 | 435 | |
436 | - $provider = $serviceManager->getProvider( $serviceItem ); |
|
437 | - $result = $provider->checkConfigFE( $attributes ); |
|
438 | - $unknown = array_diff_key( $attributes, $result ); |
|
436 | + $provider = $serviceManager->getProvider($serviceItem); |
|
437 | + $result = $provider->checkConfigFE($attributes); |
|
438 | + $unknown = array_diff_key($attributes, $result); |
|
439 | 439 | |
440 | - if( count( $unknown ) > 0 ) |
|
440 | + if (count($unknown) > 0) |
|
441 | 441 | { |
442 | - $msg = sprintf( 'Unknown attributes "%1$s"', implode( '","', array_keys( $unknown ) ) ); |
|
443 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
442 | + $msg = sprintf('Unknown attributes "%1$s"', implode('","', array_keys($unknown))); |
|
443 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
444 | 444 | } |
445 | 445 | |
446 | - foreach( $result as $key => $value ) |
|
446 | + foreach ($result as $key => $value) |
|
447 | 447 | { |
448 | - if( $value !== null ) { |
|
449 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $value ); |
|
448 | + if ($value !== null) { |
|
449 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($value); |
|
450 | 450 | } |
451 | 451 | } |
452 | 452 | |
453 | - $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager( $context, 'order/base/service' ); |
|
453 | + $orderBaseServiceManager = \Aimeos\MShop\Factory::createManager($context, 'order/base/service'); |
|
454 | 454 | $orderServiceItem = $orderBaseServiceManager->createItem(); |
455 | - $orderServiceItem->copyFrom( $serviceItem ); |
|
455 | + $orderServiceItem->copyFrom($serviceItem); |
|
456 | 456 | |
457 | 457 | // remove service rebate of original price |
458 | - $price = $provider->calcPrice( $this->get() )->setRebate( '0.00' ); |
|
459 | - $orderServiceItem->setPrice( $price ); |
|
458 | + $price = $provider->calcPrice($this->get())->setRebate('0.00'); |
|
459 | + $orderServiceItem->setPrice($price); |
|
460 | 460 | |
461 | - $provider->setConfigFE( $orderServiceItem, $attributes ); |
|
461 | + $provider->setConfigFE($orderServiceItem, $attributes); |
|
462 | 462 | |
463 | - $this->get()->setService( $orderServiceItem, $type ); |
|
463 | + $this->get()->setService($orderServiceItem, $type); |
|
464 | 464 | $this->save(); |
465 | 465 | } |
466 | 466 | |
@@ -473,18 +473,18 @@ discard block |
||
473 | 473 | * an address item. |
474 | 474 | * @throws \Aimeos\Controller\Frontend\Basket\Exception |
475 | 475 | */ |
476 | - protected function setAddressFromArray( \Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map ) |
|
476 | + protected function setAddressFromArray(\Aimeos\MShop\Order\Item\Base\Address\Iface $address, array $map) |
|
477 | 477 | { |
478 | - foreach( $map as $key => $value ) { |
|
479 | - $map[$key] = strip_tags( $value ); // prevent XSS |
|
478 | + foreach ($map as $key => $value) { |
|
479 | + $map[$key] = strip_tags($value); // prevent XSS |
|
480 | 480 | } |
481 | 481 | |
482 | - $errors = $address->fromArray( $map ); |
|
482 | + $errors = $address->fromArray($map); |
|
483 | 483 | |
484 | - if( count( $errors ) > 0 ) |
|
484 | + if (count($errors) > 0) |
|
485 | 485 | { |
486 | - $msg = sprintf( 'Invalid address properties, please check your input' ); |
|
487 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg, 0, null, $errors ); |
|
486 | + $msg = sprintf('Invalid address properties, please check your input'); |
|
487 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg, 0, null, $errors); |
|
488 | 488 | } |
489 | 489 | } |
490 | 490 | } |
@@ -15,15 +15,15 @@ discard block |
||
15 | 15 | public static function bootstrap() |
16 | 16 | { |
17 | 17 | self::getAimeos(); |
18 | - \Aimeos\MShop\Factory::setCache( false ); |
|
19 | - \Aimeos\Controller\Frontend\Factory::setCache( false ); |
|
18 | + \Aimeos\MShop\Factory::setCache(false); |
|
19 | + \Aimeos\Controller\Frontend\Factory::setCache(false); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
23 | - public static function getContext( $site = 'unittest' ) |
|
23 | + public static function getContext($site = 'unittest') |
|
24 | 24 | { |
25 | - if( !isset( self::$context[$site] ) ) { |
|
26 | - self::$context[$site] = self::createContext( $site ); |
|
25 | + if (!isset(self::$context[$site])) { |
|
26 | + self::$context[$site] = self::createContext($site); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | return clone self::$context[$site]; |
@@ -32,13 +32,13 @@ discard block |
||
32 | 32 | |
33 | 33 | private static function getAimeos() |
34 | 34 | { |
35 | - if( !isset( self::$aimeos ) ) |
|
35 | + if (!isset(self::$aimeos)) |
|
36 | 36 | { |
37 | 37 | require_once 'Bootstrap.php'; |
38 | - spl_autoload_register( 'Aimeos\\Bootstrap::autoload' ); |
|
38 | + spl_autoload_register('Aimeos\\Bootstrap::autoload'); |
|
39 | 39 | |
40 | - $extdir = dirname( dirname( dirname( dirname( dirname( __FILE__ ) ) ) ) ); |
|
41 | - self::$aimeos = new \Aimeos\Bootstrap( array( $extdir ), true ); |
|
40 | + $extdir = dirname(dirname(dirname(dirname(dirname(__FILE__))))); |
|
41 | + self::$aimeos = new \Aimeos\Bootstrap(array($extdir), true); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | return self::$aimeos; |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | /** |
49 | 49 | * @param string $site |
50 | 50 | */ |
51 | - private static function createContext( $site ) |
|
51 | + private static function createContext($site) |
|
52 | 52 | { |
53 | 53 | $ctx = new \Aimeos\MShop\Context\Item\Standard(); |
54 | 54 | $aimeos = self::getAimeos(); |
@@ -58,38 +58,38 @@ discard block |
||
58 | 58 | $paths[] = __DIR__ . DIRECTORY_SEPARATOR . 'config'; |
59 | 59 | $file = __DIR__ . DIRECTORY_SEPARATOR . 'confdoc.ser'; |
60 | 60 | |
61 | - $conf = new \Aimeos\MW\Config\PHPArray( [], $paths ); |
|
62 | - $conf = new \Aimeos\MW\Config\Decorator\Memory( $conf ); |
|
63 | - $conf = new \Aimeos\MW\Config\Decorator\Documentor( $conf, $file ); |
|
64 | - $ctx->setConfig( $conf ); |
|
61 | + $conf = new \Aimeos\MW\Config\PHPArray([], $paths); |
|
62 | + $conf = new \Aimeos\MW\Config\Decorator\Memory($conf); |
|
63 | + $conf = new \Aimeos\MW\Config\Decorator\Documentor($conf, $file); |
|
64 | + $ctx->setConfig($conf); |
|
65 | 65 | |
66 | 66 | |
67 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $conf ); |
|
68 | - $ctx->setDatabaseManager( $dbm ); |
|
67 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($conf); |
|
68 | + $ctx->setDatabaseManager($dbm); |
|
69 | 69 | |
70 | 70 | |
71 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $conf ); |
|
72 | - $ctx->setMessageQueueManager( $mq ); |
|
71 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($conf); |
|
72 | + $ctx->setMessageQueueManager($mq); |
|
73 | 73 | |
74 | 74 | |
75 | - $logger = new \Aimeos\MW\Logger\File( 'unittest.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
76 | - $ctx->setLogger( $logger ); |
|
75 | + $logger = new \Aimeos\MW\Logger\File('unittest.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
76 | + $ctx->setLogger($logger); |
|
77 | 77 | |
78 | 78 | |
79 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
80 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
79 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
80 | + $ctx->setI18n(array('de' => $i18n)); |
|
81 | 81 | |
82 | 82 | |
83 | 83 | $session = new \Aimeos\MW\Session\None(); |
84 | - $ctx->setSession( $session ); |
|
84 | + $ctx->setSession($session); |
|
85 | 85 | |
86 | 86 | |
87 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
88 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
89 | - $ctx->setLocale( $locale ); |
|
87 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
88 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
89 | + $ctx->setLocale($locale); |
|
90 | 90 | |
91 | 91 | |
92 | - $ctx->setEditor( 'core:controller/frontend' ); |
|
92 | + $ctx->setEditor('core:controller/frontend'); |
|
93 | 93 | |
94 | 94 | return $ctx; |
95 | 95 | } |
@@ -28,25 +28,25 @@ discard block |
||
28 | 28 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
29 | 29 | * @since 2017.04 |
30 | 30 | */ |
31 | - public function addItem( array $values ) |
|
31 | + public function addItem(array $values) |
|
32 | 32 | { |
33 | 33 | $context = $this->getContext(); |
34 | 34 | $config = $context->getConfig(); |
35 | 35 | |
36 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
37 | - $values = $this->addItemDefaults( $values ); |
|
36 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
37 | + $values = $this->addItemDefaults($values); |
|
38 | 38 | |
39 | 39 | try |
40 | 40 | { |
41 | - $item = $manager->findItem( $values['customer.code'] ); |
|
41 | + $item = $manager->findItem($values['customer.code']); |
|
42 | 42 | } |
43 | - catch( \Aimeos\MShop\Exception $e ) |
|
43 | + catch (\Aimeos\MShop\Exception $e) |
|
44 | 44 | { |
45 | - $this->checkLimit( $values ); |
|
45 | + $this->checkLimit($values); |
|
46 | 46 | |
47 | 47 | $item = $manager->createItem(); |
48 | - $item->fromArray( $values ); |
|
49 | - $item->setId( null ); |
|
48 | + $item->fromArray($values); |
|
49 | + $item->setId(null); |
|
50 | 50 | |
51 | 51 | /** controller/frontend/customer/groupids |
52 | 52 | * List of groups new customers should be assigned to |
@@ -60,14 +60,14 @@ discard block |
||
60 | 60 | * @category User |
61 | 61 | * @category Developer |
62 | 62 | */ |
63 | - $gids = $config->get( 'client/html/checkout/standard/order/account/standard/groupids', [] ); // @deprecated |
|
64 | - $item->setGroups( (array) $config->get( 'controller/frontend/customer/groupids', $gids ) ); |
|
63 | + $gids = $config->get('client/html/checkout/standard/order/account/standard/groupids', []); // @deprecated |
|
64 | + $item->setGroups((array) $config->get('controller/frontend/customer/groupids', $gids)); |
|
65 | 65 | |
66 | - $item = $manager->saveItem( $item ); |
|
66 | + $item = $manager->saveItem($item); |
|
67 | 67 | |
68 | 68 | $msg = $item->toArray(); |
69 | 69 | $msg['customer.password'] = $values['customer.password']; |
70 | - $context->getMessageQueue( 'mq-email', 'customer/email/account' )->add( json_encode( $msg ) ); |
|
70 | + $context->getMessageQueue('mq-email', 'customer/email/account')->add(json_encode($msg)); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | return $item; |
@@ -79,14 +79,14 @@ discard block |
||
79 | 79 | * |
80 | 80 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
81 | 81 | */ |
82 | - public function createItem( array $values = [] ) |
|
82 | + public function createItem(array $values = []) |
|
83 | 83 | { |
84 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
84 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
85 | 85 | |
86 | 86 | $item = $manager->createItem(); |
87 | - $item->fromArray( $values ); |
|
88 | - $item->setId( null ); |
|
89 | - $item->setStatus( 1 ); |
|
87 | + $item->fromArray($values); |
|
88 | + $item->setId(null); |
|
89 | + $item->setStatus(1); |
|
90 | 90 | |
91 | 91 | return $item; |
92 | 92 | } |
@@ -98,12 +98,12 @@ discard block |
||
98 | 98 | * @param string $id Unique customer ID |
99 | 99 | * @since 2017.04 |
100 | 100 | */ |
101 | - public function deleteItem( $id ) |
|
101 | + public function deleteItem($id) |
|
102 | 102 | { |
103 | - $this->checkUser( $id ); |
|
103 | + $this->checkUser($id); |
|
104 | 104 | |
105 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
106 | - $manager->deleteItem( $id ); |
|
105 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
106 | + $manager->deleteItem($id); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
116 | 116 | * @since 2017.04 |
117 | 117 | */ |
118 | - public function editItem( $id, array $values ) |
|
118 | + public function editItem($id, array $values) |
|
119 | 119 | { |
120 | - $this->checkUser( $id ); |
|
120 | + $this->checkUser($id); |
|
121 | 121 | |
122 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
123 | - $item = $manager->getItem( $id, [], true ); |
|
122 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
123 | + $item = $manager->getItem($id, [], true); |
|
124 | 124 | |
125 | - unset( $values['customer.id'] ); |
|
126 | - $item->fromArray( $values ); |
|
125 | + unset($values['customer.id']); |
|
126 | + $item->fromArray($values); |
|
127 | 127 | |
128 | - return $manager->saveItem( $item ); |
|
128 | + return $manager->saveItem($item); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | |
@@ -137,17 +137,17 @@ discard block |
||
137 | 137 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
138 | 138 | * @since 2017.04 |
139 | 139 | */ |
140 | - public function getItem( $id = null, array $domains = [] ) |
|
140 | + public function getItem($id = null, array $domains = []) |
|
141 | 141 | { |
142 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
142 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
143 | 143 | |
144 | - if( $id == null ) { |
|
145 | - return $manager->getItem( $this->getContext()->getUserId(), $domains, true ); |
|
144 | + if ($id == null) { |
|
145 | + return $manager->getItem($this->getContext()->getUserId(), $domains, true); |
|
146 | 146 | } |
147 | 147 | |
148 | - $this->checkUser( $id ); |
|
148 | + $this->checkUser($id); |
|
149 | 149 | |
150 | - return $manager->getItem( $id, $domains, true ); |
|
150 | + return $manager->getItem($id, $domains, true); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
162 | 162 | * @since 2017.04 |
163 | 163 | */ |
164 | - public function findItem( $code, array $domains = [] ) |
|
164 | + public function findItem($code, array $domains = []) |
|
165 | 165 | { |
166 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->findItem( $code, $domains ); |
|
166 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->findItem($code, $domains); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | |
@@ -173,9 +173,9 @@ discard block |
||
173 | 173 | * @param \Aimeos\MShop\Customer\Item\Iface $item Customer item |
174 | 174 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
175 | 175 | */ |
176 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
176 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item) |
|
177 | 177 | { |
178 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->saveItem( $item ); |
|
178 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->saveItem($item); |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | |
@@ -186,17 +186,17 @@ discard block |
||
186 | 186 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
187 | 187 | * @since 2017.04 |
188 | 188 | */ |
189 | - public function addAddressItem( array $values ) |
|
189 | + public function addAddressItem(array $values) |
|
190 | 190 | { |
191 | 191 | $context = $this->getContext(); |
192 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
192 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
193 | 193 | |
194 | 194 | $item = $manager->createItem(); |
195 | - $item->fromArray( $values ); |
|
196 | - $item->setId( null ); |
|
197 | - $item->setParentId( $context->getUserId() ); |
|
195 | + $item->fromArray($values); |
|
196 | + $item->setId(null); |
|
197 | + $item->setParentId($context->getUserId()); |
|
198 | 198 | |
199 | - return $manager->saveItem( $item ); |
|
199 | + return $manager->saveItem($item); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -205,16 +205,16 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
207 | 207 | */ |
208 | - public function createAddressItem( array $values = [] ) |
|
208 | + public function createAddressItem(array $values = []) |
|
209 | 209 | { |
210 | 210 | $context = $this->getContext(); |
211 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
211 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
212 | 212 | |
213 | 213 | $item = $manager->createItem(); |
214 | - $item->fromArray( $values ); |
|
215 | - $item->setId( null ); |
|
214 | + $item->fromArray($values); |
|
215 | + $item->setId(null); |
|
216 | 216 | |
217 | - $item->setParentId( $context->getUserId() ); |
|
217 | + $item->setParentId($context->getUserId()); |
|
218 | 218 | |
219 | 219 | return $item; |
220 | 220 | } |
@@ -226,13 +226,13 @@ discard block |
||
226 | 226 | * @param string $id Unique customer address ID |
227 | 227 | * @since 2017.04 |
228 | 228 | */ |
229 | - public function deleteAddressItem( $id ) |
|
229 | + public function deleteAddressItem($id) |
|
230 | 230 | { |
231 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
231 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
232 | 232 | |
233 | - $this->checkUser( $manager->getItem( $id, [], true )->getParentId() ); |
|
233 | + $this->checkUser($manager->getItem($id, [], true)->getParentId()); |
|
234 | 234 | |
235 | - $manager->deleteItem( $id ); |
|
235 | + $manager->deleteItem($id); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | |
@@ -244,17 +244,17 @@ discard block |
||
244 | 244 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
245 | 245 | * @since 2017.04 |
246 | 246 | */ |
247 | - public function editAddressItem( $id, array $values ) |
|
247 | + public function editAddressItem($id, array $values) |
|
248 | 248 | { |
249 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
249 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
250 | 250 | |
251 | - $item = $manager->getItem( $id, [], true ); |
|
252 | - $this->checkUser( $item->getParentId() ); |
|
251 | + $item = $manager->getItem($id, [], true); |
|
252 | + $this->checkUser($item->getParentId()); |
|
253 | 253 | |
254 | - unset( $values['customer.address.id'] ); |
|
255 | - $item->fromArray( $values ); |
|
254 | + unset($values['customer.address.id']); |
|
255 | + $item->fromArray($values); |
|
256 | 256 | |
257 | - return $manager->saveItem( $item ); |
|
257 | + return $manager->saveItem($item); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | |
@@ -265,12 +265,12 @@ discard block |
||
265 | 265 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
266 | 266 | * @since 2017.04 |
267 | 267 | */ |
268 | - public function getAddressItem( $id ) |
|
268 | + public function getAddressItem($id) |
|
269 | 269 | { |
270 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
270 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
271 | 271 | |
272 | - $item = $manager->getItem( $id ); |
|
273 | - $this->checkUser( $item->getParentId() ); |
|
272 | + $item = $manager->getItem($id); |
|
273 | + $this->checkUser($item->getParentId()); |
|
274 | 274 | |
275 | 275 | return $item; |
276 | 276 | } |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | * @param \Aimeos\MShop\Customer\Item\Address\Iface $item Customer address item |
283 | 283 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item including the generated ID |
284 | 284 | */ |
285 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
285 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item) |
|
286 | 286 | { |
287 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' )->saveItem( $item ); |
|
287 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address')->saveItem($item); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | |
@@ -295,32 +295,32 @@ discard block |
||
295 | 295 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
296 | 296 | * @since 2017.06 |
297 | 297 | */ |
298 | - public function addListItem( array $values ) |
|
298 | + public function addListItem(array $values) |
|
299 | 299 | { |
300 | 300 | $context = $this->getContext(); |
301 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
301 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
302 | 302 | |
303 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
303 | + if (!isset($values['customer.lists.typeid'])) |
|
304 | 304 | { |
305 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
306 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
305 | + if (!isset($values['customer.lists.type'])) { |
|
306 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
307 | 307 | } |
308 | 308 | |
309 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
310 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
309 | + if (!isset($values['customer.lists.domain'])) { |
|
310 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
311 | 311 | } |
312 | 312 | |
313 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
314 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
313 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
314 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
315 | 315 | $values['customer.lists.typeid'] = $typeItem->getId(); |
316 | 316 | } |
317 | 317 | |
318 | 318 | $item = $manager->createItem(); |
319 | - $item->fromArray( $values ); |
|
320 | - $item->setId( null ); |
|
321 | - $item->setParentId( $context->getUserId() ); |
|
319 | + $item->fromArray($values); |
|
320 | + $item->setId(null); |
|
321 | + $item->setParentId($context->getUserId()); |
|
322 | 322 | |
323 | - return $manager->saveItem( $item ); |
|
323 | + return $manager->saveItem($item); |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | |
@@ -333,10 +333,10 @@ discard block |
||
333 | 333 | public function createListsFilter() |
334 | 334 | { |
335 | 335 | $context = $this->getContext(); |
336 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
336 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
337 | 337 | |
338 | 338 | $filter = $manager->createSearch(); |
339 | - $filter->setConditions( $filter->compare( '==', 'customer.lists.parentid', $context->getUserId() ) ); |
|
339 | + $filter->setConditions($filter->compare('==', 'customer.lists.parentid', $context->getUserId())); |
|
340 | 340 | |
341 | 341 | return $filter; |
342 | 342 | } |
@@ -348,13 +348,13 @@ discard block |
||
348 | 348 | * @param string $id Unique customer address ID |
349 | 349 | * @since 2017.06 |
350 | 350 | */ |
351 | - public function deleteListItem( $id ) |
|
351 | + public function deleteListItem($id) |
|
352 | 352 | { |
353 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
353 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
354 | 354 | |
355 | - $this->checkUser( $manager->getItem( $id )->getParentId() ); |
|
355 | + $this->checkUser($manager->getItem($id)->getParentId()); |
|
356 | 356 | |
357 | - $manager->deleteItem( $id ); |
|
357 | + $manager->deleteItem($id); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
@@ -366,33 +366,33 @@ discard block |
||
366 | 366 | * @return \Aimeos\MShop\Common\Item\Lists\Iface Customer lists item |
367 | 367 | * @since 2017.06 |
368 | 368 | */ |
369 | - public function editListItem( $id, array $values ) |
|
369 | + public function editListItem($id, array $values) |
|
370 | 370 | { |
371 | 371 | $context = $this->getContext(); |
372 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists' ); |
|
372 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists'); |
|
373 | 373 | |
374 | - $item = $manager->getItem( $id, [], true ); |
|
375 | - $this->checkUser( $item->getParentId() ); |
|
374 | + $item = $manager->getItem($id, [], true); |
|
375 | + $this->checkUser($item->getParentId()); |
|
376 | 376 | |
377 | - if( !isset( $values['customer.lists.typeid'] ) ) |
|
377 | + if (!isset($values['customer.lists.typeid'])) |
|
378 | 378 | { |
379 | - if( !isset( $values['customer.lists.type'] ) ) { |
|
380 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists type code' ) ); |
|
379 | + if (!isset($values['customer.lists.type'])) { |
|
380 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists type code')); |
|
381 | 381 | } |
382 | 382 | |
383 | - if( !isset( $values['customer.lists.domain'] ) ) { |
|
384 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( sprintf( 'No customer lists domain' ) ); |
|
383 | + if (!isset($values['customer.lists.domain'])) { |
|
384 | + throw new \Aimeos\Controller\Frontend\Customer\Exception(sprintf('No customer lists domain')); |
|
385 | 385 | } |
386 | 386 | |
387 | - $typeManager = \Aimeos\MShop\Factory::createManager( $context, 'customer/lists/type' ); |
|
388 | - $typeItem = $typeManager->findItem( $values['customer.lists.type'], [], $values['customer.lists.domain'] ); |
|
387 | + $typeManager = \Aimeos\MShop\Factory::createManager($context, 'customer/lists/type'); |
|
388 | + $typeItem = $typeManager->findItem($values['customer.lists.type'], [], $values['customer.lists.domain']); |
|
389 | 389 | $values['customer.lists.typeid'] = $typeItem->getId(); |
390 | 390 | } |
391 | 391 | |
392 | - unset( $values['customer.lists.id'] ); |
|
393 | - $item->fromArray( $values ); |
|
392 | + unset($values['customer.lists.id']); |
|
393 | + $item->fromArray($values); |
|
394 | 394 | |
395 | - return $manager->saveItem( $item ); |
|
395 | + return $manager->saveItem($item); |
|
396 | 396 | } |
397 | 397 | |
398 | 398 | |
@@ -403,12 +403,12 @@ discard block |
||
403 | 403 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
404 | 404 | * @since 2017.06 |
405 | 405 | */ |
406 | - public function getListItem( $id ) |
|
406 | + public function getListItem($id) |
|
407 | 407 | { |
408 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
409 | - $item = $manager->getItem( $id ); |
|
408 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
409 | + $item = $manager->getItem($id); |
|
410 | 410 | |
411 | - $this->checkUser( $item->getParentId() ); |
|
411 | + $this->checkUser($item->getParentId()); |
|
412 | 412 | |
413 | 413 | return $item; |
414 | 414 | } |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | * @return \Aimeos\MShop\Common\Item\Lists\Iface[] Customer list items |
423 | 423 | * @since 2017.06 |
424 | 424 | */ |
425 | - public function searchListItems( \Aimeos\MW\Criteria\Iface $filter, &$total = null ) |
|
425 | + public function searchListItems(\Aimeos\MW\Criteria\Iface $filter, &$total = null) |
|
426 | 426 | { |
427 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/lists' ); |
|
427 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/lists'); |
|
428 | 428 | |
429 | - return $manager->searchItems( $filter, [], $total ); |
|
429 | + return $manager->searchItems($filter, [], $total); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | |
@@ -436,37 +436,37 @@ discard block |
||
436 | 436 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
437 | 437 | * @return string[] Associative list of customer key/value pairs with default values set |
438 | 438 | */ |
439 | - protected function addItemDefaults( array $values ) |
|
439 | + protected function addItemDefaults(array $values) |
|
440 | 440 | { |
441 | - if( !isset( $values['customer.label'] ) || $values['customer.label'] == '' ) |
|
441 | + if (!isset($values['customer.label']) || $values['customer.label'] == '') |
|
442 | 442 | { |
443 | 443 | $label = ''; |
444 | 444 | |
445 | - if( isset( $values['customer.lastname'] ) ) { |
|
445 | + if (isset($values['customer.lastname'])) { |
|
446 | 446 | $label = $values['customer.lastname']; |
447 | 447 | } |
448 | 448 | |
449 | - if( isset( $values['customer.firstname'] ) && $values['customer.firstname'] != '' ) { |
|
449 | + if (isset($values['customer.firstname']) && $values['customer.firstname'] != '') { |
|
450 | 450 | $label = $values['customer.firstname'] . ' ' . $label; |
451 | 451 | } |
452 | 452 | |
453 | - if( isset( $values['customer.company'] ) && $values['customer.company'] != '' ) { |
|
453 | + if (isset($values['customer.company']) && $values['customer.company'] != '') { |
|
454 | 454 | $label .= ' (' . $values['customer.company'] . ')'; |
455 | 455 | } |
456 | 456 | |
457 | 457 | $values['customer.label'] = $label; |
458 | 458 | } |
459 | 459 | |
460 | - if( !isset( $values['customer.code'] ) ) { |
|
460 | + if (!isset($values['customer.code'])) { |
|
461 | 461 | $values['customer.code'] = $values['customer.email']; |
462 | 462 | } |
463 | 463 | |
464 | - if( !isset( $values['customer.status'] ) ) { |
|
464 | + if (!isset($values['customer.status'])) { |
|
465 | 465 | $values['customer.status'] = 1; |
466 | 466 | } |
467 | 467 | |
468 | - if( !isset( $values['customer.password'] ) ) { |
|
469 | - $values['customer.password'] = substr( md5( microtime( true ) . getmypid() . rand() ), -8 ); |
|
468 | + if (!isset($values['customer.password'])) { |
|
469 | + $values['customer.password'] = substr(md5(microtime(true) . getmypid() . rand()), -8); |
|
470 | 470 | } |
471 | 471 | |
472 | 472 | return $values; |
@@ -479,7 +479,7 @@ discard block |
||
479 | 479 | * @param string[] $values Associative list of customer keys (e.g. "customer.label") and their values |
480 | 480 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
481 | 481 | */ |
482 | - protected function checkLimit( array $values ) |
|
482 | + protected function checkLimit(array $values) |
|
483 | 483 | { |
484 | 484 | $total = 0; |
485 | 485 | $context = $this->getContext(); |
@@ -500,7 +500,7 @@ discard block |
||
500 | 500 | * @category Developer |
501 | 501 | * @see controller/frontend/customer/limit-seconds |
502 | 502 | */ |
503 | - $count = $config->get( 'controller/frontend/customer/limit-count', 5 ); |
|
503 | + $count = $config->get('controller/frontend/customer/limit-count', 5); |
|
504 | 504 | |
505 | 505 | /** controller/frontend/customer/limit-seconds |
506 | 506 | * Customer account limitation time frame in seconds |
@@ -518,22 +518,22 @@ discard block |
||
518 | 518 | * @category Developer |
519 | 519 | * @see controller/frontend/customer/limit-count |
520 | 520 | */ |
521 | - $seconds = $config->get( 'controller/frontend/customer/limit-seconds', 300 ); |
|
521 | + $seconds = $config->get('controller/frontend/customer/limit-seconds', 300); |
|
522 | 522 | |
523 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
523 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
524 | 524 | |
525 | 525 | $search = $manager->createSearch(); |
526 | 526 | $expr = [ |
527 | - $search->compare( '==', 'customer.editor', $context->getEditor() ), |
|
528 | - $search->compare( '>=', 'customer.ctime', date( 'Y-m-d H:i:s', time() - $seconds ) ), |
|
527 | + $search->compare('==', 'customer.editor', $context->getEditor()), |
|
528 | + $search->compare('>=', 'customer.ctime', date('Y-m-d H:i:s', time() - $seconds)), |
|
529 | 529 | ]; |
530 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
531 | - $search->setSlice( 0, 0 ); |
|
530 | + $search->setConditions($search->combine('&&', $expr)); |
|
531 | + $search->setSlice(0, 0); |
|
532 | 532 | |
533 | - $manager->searchItems( $search, [], $total ); |
|
533 | + $manager->searchItems($search, [], $total); |
|
534 | 534 | |
535 | - if( $total > $count ) { |
|
536 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( sprintf( 'Temporary limit reached' ) ); |
|
535 | + if ($total > $count) { |
|
536 | + throw new \Aimeos\Controller\Frontend\Basket\Exception(sprintf('Temporary limit reached')); |
|
537 | 537 | } |
538 | 538 | } |
539 | 539 | |
@@ -544,12 +544,12 @@ discard block |
||
544 | 544 | * @param string $id Unique customer ID |
545 | 545 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
546 | 546 | */ |
547 | - protected function checkUser( $id ) |
|
547 | + protected function checkUser($id) |
|
548 | 548 | { |
549 | - if( $id != $this->getContext()->getUserId() ) |
|
549 | + if ($id != $this->getContext()->getUserId()) |
|
550 | 550 | { |
551 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
552 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
551 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
552 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
553 | 553 | } |
554 | 554 | } |
555 | 555 | } |
@@ -18,123 +18,123 @@ discard block |
||
18 | 18 | protected function setUp() |
19 | 19 | { |
20 | 20 | $this->context = \TestHelperFrontend::getContext(); |
21 | - $this->object = new \Aimeos\Controller\Frontend\Customer\Standard( $this->context ); |
|
21 | + $this->object = new \Aimeos\Controller\Frontend\Customer\Standard($this->context); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
25 | 25 | protected function tearDown() |
26 | 26 | { |
27 | - unset( $this->context, $this->object ); |
|
27 | + unset($this->context, $this->object); |
|
28 | 28 | } |
29 | 29 | |
30 | 30 | |
31 | 31 | public function testAddEditSaveDeleteItem() |
32 | 32 | { |
33 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
34 | - $id = $manager->findItem( 'UTC001' )->getId(); |
|
33 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
34 | + $id = $manager->findItem('UTC001')->getId(); |
|
35 | 35 | |
36 | - $this->context->setUserId( $id ); |
|
37 | - $item = $this->object->addItem( ['customer.code' => 'unittest-ctnl', 'customer.status' => 1] ); |
|
38 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
36 | + $this->context->setUserId($id); |
|
37 | + $item = $this->object->addItem(['customer.code' => 'unittest-ctnl', 'customer.status' => 1]); |
|
38 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
39 | 39 | |
40 | - $this->context->setUserId( $item->getId() ); |
|
41 | - $item = $this->object->editItem( $item->getId(), ['customer.code' => 'unittest-ctnl2'] ); |
|
42 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
40 | + $this->context->setUserId($item->getId()); |
|
41 | + $item = $this->object->editItem($item->getId(), ['customer.code' => 'unittest-ctnl2']); |
|
42 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
43 | 43 | |
44 | - $item->setStatus( 0 ); |
|
45 | - $item = $this->object->saveItem( $item ); |
|
46 | - $this->assertEquals( 0, $item->getStatus() ); |
|
44 | + $item->setStatus(0); |
|
45 | + $item = $this->object->saveItem($item); |
|
46 | + $this->assertEquals(0, $item->getStatus()); |
|
47 | 47 | |
48 | - $this->object->deleteItem( $item->getId() ); |
|
48 | + $this->object->deleteItem($item->getId()); |
|
49 | 49 | |
50 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
51 | - $manager->findItem( 'unittest-ctnl' ); |
|
50 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
51 | + $manager->findItem('unittest-ctnl'); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | |
55 | 55 | public function testAddExistingItem() |
56 | 56 | { |
57 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
57 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
58 | 58 | |
59 | - $item = $this->object->addItem( ['customer.code' => 'UTC001'] ); |
|
60 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $item ); |
|
59 | + $item = $this->object->addItem(['customer.code' => 'UTC001']); |
|
60 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $item); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | |
64 | 64 | public function testCreateItem() |
65 | 65 | { |
66 | 66 | $result = $this->object->createItem(); |
67 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
67 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | |
71 | 71 | public function testGetItem() |
72 | 72 | { |
73 | - $id = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' )->getId(); |
|
74 | - $this->context->setUserId( $id ); |
|
73 | + $id = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001')->getId(); |
|
74 | + $this->context->setUserId($id); |
|
75 | 75 | |
76 | - $result = $this->object->getItem( $id, ['customer/address', 'text'] ); |
|
76 | + $result = $this->object->getItem($id, ['customer/address', 'text']); |
|
77 | 77 | |
78 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
79 | - $this->assertEquals( 1, count( $result->getRefItems( 'text' ) ) ); |
|
80 | - $this->assertEquals( 1, count( $result->getAddressItems() ) ); |
|
78 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
79 | + $this->assertEquals(1, count($result->getRefItems('text'))); |
|
80 | + $this->assertEquals(1, count($result->getAddressItems())); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | |
84 | 84 | public function testFindItem() |
85 | 85 | { |
86 | - $result = $this->object->findItem( 'UTC001' ); |
|
87 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Iface', $result ); |
|
86 | + $result = $this->object->findItem('UTC001'); |
|
87 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Iface', $result); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | public function testAddEditSaveDeleteAddressItem() |
92 | 92 | { |
93 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
94 | - $this->context->setUserId( $customer->getId() ); |
|
93 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
94 | + $this->context->setUserId($customer->getId()); |
|
95 | 95 | |
96 | - $item = $this->object->addAddressItem( ['customer.address.lastname' => 'unittest-ctnl'] ); |
|
97 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
96 | + $item = $this->object->addAddressItem(['customer.address.lastname' => 'unittest-ctnl']); |
|
97 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
98 | 98 | |
99 | - $item = $this->object->editAddressItem( $item->getId(), ['customer.address.lastname' => 'unittest-ctnl2'] ); |
|
100 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $item ); |
|
99 | + $item = $this->object->editAddressItem($item->getId(), ['customer.address.lastname' => 'unittest-ctnl2']); |
|
100 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $item); |
|
101 | 101 | |
102 | - $item->setLastName( 'test' ); |
|
103 | - $this->object->saveAddressItem( $item ); |
|
104 | - $this->assertEquals( 'test', $item->getLastName() ); |
|
102 | + $item->setLastName('test'); |
|
103 | + $this->object->saveAddressItem($item); |
|
104 | + $this->assertEquals('test', $item->getLastName()); |
|
105 | 105 | |
106 | - $this->object->deleteAddressItem( $item->getId() ); |
|
106 | + $this->object->deleteAddressItem($item->getId()); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | |
110 | 110 | public function testCreateAddressItem() |
111 | 111 | { |
112 | 112 | $result = $this->object->createAddressItem(); |
113 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
113 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | |
117 | 117 | public function testGetAddressItem() |
118 | 118 | { |
119 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/address' ); |
|
119 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/address'); |
|
120 | 120 | $search = $manager->createSearch(); |
121 | - $search->setSlice( 0, 1 ); |
|
122 | - $result = $manager->searchItems( $search ); |
|
121 | + $search->setSlice(0, 1); |
|
122 | + $result = $manager->searchItems($search); |
|
123 | 123 | |
124 | - if( ( $item = reset( $result ) ) === false ) { |
|
125 | - throw new \RuntimeException( 'No customer address available' ); |
|
124 | + if (($item = reset($result)) === false) { |
|
125 | + throw new \RuntimeException('No customer address available'); |
|
126 | 126 | } |
127 | 127 | |
128 | - $this->context->setUserId( $item->getParentId() ); |
|
129 | - $result = $this->object->getAddressItem( $item->getId() ); |
|
130 | - $this->assertInstanceOf( '\Aimeos\MShop\Customer\Item\Address\Iface', $result ); |
|
128 | + $this->context->setUserId($item->getParentId()); |
|
129 | + $result = $this->object->getAddressItem($item->getId()); |
|
130 | + $this->assertInstanceOf('\Aimeos\MShop\Customer\Item\Address\Iface', $result); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | |
134 | 134 | public function testAddEditDeleteListItem() |
135 | 135 | { |
136 | - $customer = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' )->findItem( 'UTC001' ); |
|
137 | - $this->context->setUserId( $customer->getId() ); |
|
136 | + $customer = \Aimeos\MShop\Factory::createManager($this->context, 'customer')->findItem('UTC001'); |
|
137 | + $this->context->setUserId($customer->getId()); |
|
138 | 138 | |
139 | 139 | $values = [ |
140 | 140 | 'customer.lists.type' => 'favorite', |
@@ -142,8 +142,8 @@ discard block |
||
142 | 142 | 'customer.lists.refid' => '-1' |
143 | 143 | ]; |
144 | 144 | |
145 | - $item = $this->object->addListItem( $values ); |
|
146 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
145 | + $item = $this->object->addListItem($values); |
|
146 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
147 | 147 | |
148 | 148 | $values = [ |
149 | 149 | 'customer.lists.type' => 'favorite', |
@@ -151,46 +151,46 @@ discard block |
||
151 | 151 | 'customer.lists.refid' => '-2' |
152 | 152 | ]; |
153 | 153 | |
154 | - $item = $this->object->editListItem( $item->getId(), $values ); |
|
155 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
154 | + $item = $this->object->editListItem($item->getId(), $values); |
|
155 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
156 | 156 | |
157 | - $this->object->deleteListItem( $item->getId() ); |
|
157 | + $this->object->deleteListItem($item->getId()); |
|
158 | 158 | |
159 | - $this->setExpectedException( '\Aimeos\MShop\Exception' ); |
|
160 | - $this->object->getListItem( $item->getId() ); |
|
159 | + $this->setExpectedException('\Aimeos\MShop\Exception'); |
|
160 | + $this->object->getListItem($item->getId()); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | |
164 | 164 | public function testGetListItem() |
165 | 165 | { |
166 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer/lists' ); |
|
166 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer/lists'); |
|
167 | 167 | $search = $manager->createSearch(); |
168 | - $search->setSlice( 0, 1 ); |
|
169 | - $result = $manager->searchItems( $search ); |
|
168 | + $search->setSlice(0, 1); |
|
169 | + $result = $manager->searchItems($search); |
|
170 | 170 | |
171 | - if( ( $item = reset( $result ) ) === false ) { |
|
172 | - throw new \RuntimeException( 'No customer lists item available' ); |
|
171 | + if (($item = reset($result)) === false) { |
|
172 | + throw new \RuntimeException('No customer lists item available'); |
|
173 | 173 | } |
174 | 174 | |
175 | - $this->context->setUserId( $item->getParentId() ); |
|
176 | - $result = $this->object->getListItem( $item->getId() ); |
|
177 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $result ); |
|
175 | + $this->context->setUserId($item->getParentId()); |
|
176 | + $result = $this->object->getListItem($item->getId()); |
|
177 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $result); |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | |
181 | 181 | public function testSearchListItem() |
182 | 182 | { |
183 | - $manager = \Aimeos\MShop\Factory::createManager( $this->context, 'customer' ); |
|
184 | - $customer = $manager->findItem( 'UTC001' ); |
|
185 | - $this->context->setUserId( $customer->getId() ); |
|
183 | + $manager = \Aimeos\MShop\Factory::createManager($this->context, 'customer'); |
|
184 | + $customer = $manager->findItem('UTC001'); |
|
185 | + $this->context->setUserId($customer->getId()); |
|
186 | 186 | |
187 | 187 | $filter = $this->object->createListsFilter(); |
188 | - $result = $this->object->searchListItems( $filter ); |
|
188 | + $result = $this->object->searchListItems($filter); |
|
189 | 189 | |
190 | - foreach( $result as $item ) |
|
190 | + foreach ($result as $item) |
|
191 | 191 | { |
192 | - $this->assertEquals( $customer->getId(), $item->getParentId() ); |
|
193 | - $this->assertInstanceOf( '\Aimeos\MShop\Common\Item\Lists\Iface', $item ); |
|
192 | + $this->assertEquals($customer->getId(), $item->getParentId()); |
|
193 | + $this->assertInstanceOf('\Aimeos\MShop\Common\Item\Lists\Iface', $item); |
|
194 | 194 | } |
195 | 195 | } |
196 | 196 | } |