@@ -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,34 +58,34 @@ 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 | - $logger = new \Aimeos\MW\Logger\File( 'unittest.log', \Aimeos\MW\Logger\Base::DEBUG ); |
|
72 | - $ctx->setLogger( $logger ); |
|
71 | + $logger = new \Aimeos\MW\Logger\File('unittest.log', \Aimeos\MW\Logger\Base::DEBUG); |
|
72 | + $ctx->setLogger($logger); |
|
73 | 73 | |
74 | 74 | |
75 | - $i18n = new \Aimeos\MW\Translation\None( 'de' ); |
|
76 | - $ctx->setI18n( array( 'de' => $i18n ) ); |
|
75 | + $i18n = new \Aimeos\MW\Translation\None('de'); |
|
76 | + $ctx->setI18n(array('de' => $i18n)); |
|
77 | 77 | |
78 | 78 | |
79 | 79 | $session = new \Aimeos\MW\Session\None(); |
80 | - $ctx->setSession( $session ); |
|
80 | + $ctx->setSession($session); |
|
81 | 81 | |
82 | 82 | |
83 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx ); |
|
84 | - $locale = $localeManager->bootstrap( $site, '', '', false ); |
|
85 | - $ctx->setLocale( $locale ); |
|
83 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx); |
|
84 | + $locale = $localeManager->bootstrap($site, '', '', false); |
|
85 | + $ctx->setLocale($locale); |
|
86 | 86 | |
87 | 87 | |
88 | - $ctx->setEditor( 'core:controller/frontend' ); |
|
88 | + $ctx->setEditor('core:controller/frontend'); |
|
89 | 89 | |
90 | 90 | return $ctx; |
91 | 91 | } |
@@ -41,15 +41,15 @@ discard block |
||
41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
45 | 45 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
46 | - $stocktype = 'default' ) |
|
46 | + $stocktype = 'default') |
|
47 | 47 | { |
48 | 48 | $context = $this->getContext(); |
49 | - $productManager = \Aimeos\MShop\Factory::createManager( $context, 'product' ); |
|
50 | - $productItem = $productManager->getItem( $prodid, [], true ); |
|
49 | + $productManager = \Aimeos\MShop\Factory::createManager($context, 'product'); |
|
50 | + $productItem = $productManager->getItem($prodid, [], true); |
|
51 | 51 | |
52 | - if( $productItem->getType() !== 'bundle' ) |
|
52 | + if ($productItem->getType() !== 'bundle') |
|
53 | 53 | { |
54 | 54 | return $this->getController()->addProduct( |
55 | 55 | $prodid, $quantity, $options, $variantAttributeIds, $configAttributeIds, |
@@ -57,30 +57,30 @@ discard block |
||
57 | 57 | ); |
58 | 58 | } |
59 | 59 | |
60 | - $productItem = $productManager->getItem( $prodid, array( 'media', 'supplier', 'price', 'product', 'text' ), true ); |
|
60 | + $productItem = $productManager->getItem($prodid, array('media', 'supplier', 'price', 'product', 'text'), true); |
|
61 | 61 | |
62 | - $orderBaseProductItem = \Aimeos\MShop\Factory::createManager( $context, 'order/base/product' )->createItem(); |
|
63 | - $orderBaseProductItem->copyFrom( $productItem ); |
|
64 | - $orderBaseProductItem->setQuantity( $quantity ); |
|
65 | - $orderBaseProductItem->setStockType( $stocktype ); |
|
62 | + $orderBaseProductItem = \Aimeos\MShop\Factory::createManager($context, 'order/base/product')->createItem(); |
|
63 | + $orderBaseProductItem->copyFrom($productItem); |
|
64 | + $orderBaseProductItem->setQuantity($quantity); |
|
65 | + $orderBaseProductItem->setStockType($stocktype); |
|
66 | 66 | |
67 | - $prices = $productItem->getRefItems( 'price', 'default', 'default' ); |
|
68 | - $this->addBundleProducts( $orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype ); |
|
67 | + $prices = $productItem->getRefItems('price', 'default', 'default'); |
|
68 | + $this->addBundleProducts($orderBaseProductItem, $productItem, $variantAttributeIds, $stocktype); |
|
69 | 69 | |
70 | - $priceManager = \Aimeos\MShop\Factory::createManager( $context, 'price' ); |
|
71 | - $price = $priceManager->getLowestPrice( $prices, $quantity ); |
|
70 | + $priceManager = \Aimeos\MShop\Factory::createManager($context, 'price'); |
|
71 | + $price = $priceManager->getLowestPrice($prices, $quantity); |
|
72 | 72 | |
73 | - $attr = $this->createOrderProductAttributes( $price, $prodid, $quantity, $configAttributeIds, 'config' ); |
|
74 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, $hiddenAttributeIds, 'hidden' ) ); |
|
75 | - $attr = array_merge( $attr, $this->createOrderProductAttributes( $price, $prodid, $quantity, array_keys( $customAttributeValues ), 'custom', $customAttributeValues ) ); |
|
73 | + $attr = $this->createOrderProductAttributes($price, $prodid, $quantity, $configAttributeIds, 'config'); |
|
74 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, $hiddenAttributeIds, 'hidden')); |
|
75 | + $attr = array_merge($attr, $this->createOrderProductAttributes($price, $prodid, $quantity, array_keys($customAttributeValues), 'custom', $customAttributeValues)); |
|
76 | 76 | |
77 | 77 | // remove product rebate of original price in favor to rebates granted for the order |
78 | - $price->setRebate( '0.00' ); |
|
78 | + $price->setRebate('0.00'); |
|
79 | 79 | |
80 | - $orderBaseProductItem->setPrice( $price ); |
|
81 | - $orderBaseProductItem->setAttributes( $attr ); |
|
80 | + $orderBaseProductItem->setPrice($price); |
|
81 | + $orderBaseProductItem->setAttributes($attr); |
|
82 | 82 | |
83 | - $this->getController()->get()->addProduct( $orderBaseProductItem ); |
|
83 | + $this->getController()->get()->addProduct($orderBaseProductItem); |
|
84 | 84 | $this->getController()->save(); |
85 | 85 | } |
86 | 86 | |
@@ -93,43 +93,43 @@ discard block |
||
93 | 93 | * @param array $variantAttributeIds List of product variant attribute IDs |
94 | 94 | * @param string $stocktype |
95 | 95 | */ |
96 | - protected function addBundleProducts( \Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
97 | - \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype ) |
|
96 | + protected function addBundleProducts(\Aimeos\MShop\Order\Item\Base\Product\Iface $orderBaseProductItem, |
|
97 | + \Aimeos\MShop\Product\Item\Iface $productItem, array $variantAttributeIds, $stocktype) |
|
98 | 98 | { |
99 | 99 | $quantity = $orderBaseProductItem->getQuantity(); |
100 | 100 | $products = $subProductIds = $orderProducts = []; |
101 | - $orderProductManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'order/base/product' ); |
|
101 | + $orderProductManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'order/base/product'); |
|
102 | 102 | |
103 | - foreach( $productItem->getRefItems( 'product', null, 'default' ) as $item ) { |
|
103 | + foreach ($productItem->getRefItems('product', null, 'default') as $item) { |
|
104 | 104 | $subProductIds[] = $item->getId(); |
105 | 105 | } |
106 | 106 | |
107 | - if( count( $subProductIds ) > 0 ) |
|
107 | + if (count($subProductIds) > 0) |
|
108 | 108 | { |
109 | - $productManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'product' ); |
|
109 | + $productManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'product'); |
|
110 | 110 | |
111 | - $search = $productManager->createSearch( true ); |
|
111 | + $search = $productManager->createSearch(true); |
|
112 | 112 | $expr = array( |
113 | - $search->compare( '==', 'product.id', $subProductIds ), |
|
113 | + $search->compare('==', 'product.id', $subProductIds), |
|
114 | 114 | $search->getConditions(), |
115 | 115 | ); |
116 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
116 | + $search->setConditions($search->combine('&&', $expr)); |
|
117 | 117 | |
118 | - $products = $productManager->searchItems( $search, array( 'attribute', 'media', 'price', 'text' ) ); |
|
118 | + $products = $productManager->searchItems($search, array('attribute', 'media', 'price', 'text')); |
|
119 | 119 | } |
120 | 120 | |
121 | - foreach( $products as $product ) |
|
121 | + foreach ($products as $product) |
|
122 | 122 | { |
123 | - $prices = $product->getRefItems( 'price', 'default', 'default' ); |
|
123 | + $prices = $product->getRefItems('price', 'default', 'default'); |
|
124 | 124 | |
125 | 125 | $orderProduct = $orderProductManager->createItem(); |
126 | - $orderProduct->copyFrom( $product ); |
|
127 | - $orderProduct->setStockType( $stocktype ); |
|
128 | - $orderProduct->setPrice( $this->calcPrice( $orderProduct, $prices, $quantity ) ); |
|
126 | + $orderProduct->copyFrom($product); |
|
127 | + $orderProduct->setStockType($stocktype); |
|
128 | + $orderProduct->setPrice($this->calcPrice($orderProduct, $prices, $quantity)); |
|
129 | 129 | |
130 | 130 | $orderProducts[] = $orderProduct; |
131 | 131 | } |
132 | 132 | |
133 | - $orderBaseProductItem->setProducts( $orderProducts ); |
|
133 | + $orderBaseProductItem->setProducts($orderProducts); |
|
134 | 134 | } |
135 | 135 | } |
@@ -41,27 +41,27 @@ |
||
41 | 41 | * @param string $stocktype Unique code of the stock type to deliver the products from |
42 | 42 | * @throws \Aimeos\Controller\Frontend\Basket\Exception If the product isn't available |
43 | 43 | */ |
44 | - public function addProduct( $prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
44 | + public function addProduct($prodid, $quantity = 1, array $options = [], array $variantAttributeIds = [], |
|
45 | 45 | array $configAttributeIds = [], array $hiddenAttributeIds = [], array $customAttributeValues = [], |
46 | - $stocktype = 'default' ) |
|
46 | + $stocktype = 'default') |
|
47 | 47 | { |
48 | - $catalogListManager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'catalog/lists' ); |
|
48 | + $catalogListManager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'catalog/lists'); |
|
49 | 49 | |
50 | - $search = $catalogListManager->createSearch( true ); |
|
50 | + $search = $catalogListManager->createSearch(true); |
|
51 | 51 | $expr = array( |
52 | - $search->compare( '==', 'catalog.lists.domain', 'product' ), |
|
53 | - $search->compare( '==', 'catalog.lists.refid', $prodid ), |
|
52 | + $search->compare('==', 'catalog.lists.domain', 'product'), |
|
53 | + $search->compare('==', 'catalog.lists.refid', $prodid), |
|
54 | 54 | $search->getConditions() |
55 | 55 | ); |
56 | - $search->setConditions( $search->combine( '&&', $expr ) ); |
|
57 | - $search->setSlice( 0, 1 ); |
|
56 | + $search->setConditions($search->combine('&&', $expr)); |
|
57 | + $search->setSlice(0, 1); |
|
58 | 58 | |
59 | - $result = $catalogListManager->searchItems( $search ); |
|
59 | + $result = $catalogListManager->searchItems($search); |
|
60 | 60 | |
61 | - if( reset( $result ) === false ) |
|
61 | + if (reset($result) === false) |
|
62 | 62 | { |
63 | - $msg = sprintf( 'Adding product with ID "%1$s" is not allowed', $prodid ); |
|
64 | - throw new \Aimeos\Controller\Frontend\Basket\Exception( $msg ); |
|
63 | + $msg = sprintf('Adding product with ID "%1$s" is not allowed', $prodid); |
|
64 | + throw new \Aimeos\Controller\Frontend\Basket\Exception($msg); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | $this->getController()->addProduct( |
@@ -32,9 +32,9 @@ |
||
32 | 32 | * @param \Exception $previous The previous exception used for the exception chaining. |
33 | 33 | * @param array $list The associative list of errors and their messages when several errors occured |
34 | 34 | */ |
35 | - public function __construct( $msg = '', $code = 0, \Exception $previous = null, array $list = [] ) |
|
35 | + public function __construct($msg = '', $code = 0, \Exception $previous = null, array $list = []) |
|
36 | 36 | { |
37 | - parent::__construct( $msg, $code, $previous ); |
|
37 | + parent::__construct($msg, $code, $previous); |
|
38 | 38 | |
39 | 39 | $this->list = $list; |
40 | 40 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @param string $classname Full name of the class for which the object should be returned |
32 | 32 | * @param \Aimeos\Controller\Frontend\Iface|null $controller Frontend controller object |
33 | 33 | */ |
34 | - public static function injectController( $classname, \Aimeos\Controller\Frontend\Iface $controller = null ) |
|
34 | + public static function injectController($classname, \Aimeos\Controller\Frontend\Iface $controller = null) |
|
35 | 35 | { |
36 | 36 | self::$objects[$classname] = $controller; |
37 | 37 | } |
@@ -46,29 +46,29 @@ discard block |
||
46 | 46 | * @param string $classprefix Decorator class prefix, e.g. "\Aimeos\Controller\Frontend\Basket\Decorator\" |
47 | 47 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
48 | 48 | */ |
49 | - protected static function addDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
50 | - \Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix ) |
|
49 | + protected static function addDecorators(\Aimeos\MShop\Context\Item\Iface $context, |
|
50 | + \Aimeos\Controller\Frontend\Iface $controller, array $decorators, $classprefix) |
|
51 | 51 | { |
52 | 52 | $iface = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\Iface'; |
53 | 53 | |
54 | - foreach( $decorators as $name ) |
|
54 | + foreach ($decorators as $name) |
|
55 | 55 | { |
56 | - if( ctype_alnum( $name ) === false ) |
|
56 | + if (ctype_alnum($name) === false) |
|
57 | 57 | { |
58 | - $classname = is_string( $name ) ? $classprefix . $name : '<not a string>'; |
|
59 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in class name "%1$s"', $classname ) ); |
|
58 | + $classname = is_string($name) ? $classprefix . $name : '<not a string>'; |
|
59 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in class name "%1$s"', $classname)); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | $classname = $classprefix . $name; |
63 | 63 | |
64 | - if( class_exists( $classname ) === false ) { |
|
65 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
64 | + if (class_exists($classname) === false) { |
|
65 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname)); |
|
66 | 66 | } |
67 | 67 | |
68 | - $controller = new $classname( $controller, $context ); |
|
68 | + $controller = new $classname($controller, $context); |
|
69 | 69 | |
70 | - if( !( $controller instanceof $iface ) ) { |
|
71 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $iface ) ); |
|
70 | + if (!($controller instanceof $iface)) { |
|
71 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $iface)); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -84,14 +84,14 @@ discard block |
||
84 | 84 | * @param string $domain Domain name in lower case, e.g. "product" |
85 | 85 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
86 | 86 | */ |
87 | - protected static function addControllerDecorators( \Aimeos\MShop\Context\Item\Iface $context, |
|
88 | - \Aimeos\Controller\Frontend\Iface $controller, $domain ) |
|
87 | + protected static function addControllerDecorators(\Aimeos\MShop\Context\Item\Iface $context, |
|
88 | + \Aimeos\Controller\Frontend\Iface $controller, $domain) |
|
89 | 89 | { |
90 | - if( !is_string( $domain ) || $domain === '' ) { |
|
91 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid domain "%1$s"', $domain ) ); |
|
90 | + if (!is_string($domain) || $domain === '') { |
|
91 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid domain "%1$s"', $domain)); |
|
92 | 92 | } |
93 | 93 | |
94 | - $localClass = str_replace( ' ', '\\', ucwords( str_replace( '/', ' ', $domain ) ) ); |
|
94 | + $localClass = str_replace(' ', '\\', ucwords(str_replace('/', ' ', $domain))); |
|
95 | 95 | $config = $context->getConfig(); |
96 | 96 | |
97 | 97 | /** controller/frontend/common/decorators/default |
@@ -116,26 +116,26 @@ discard block |
||
116 | 116 | * @since 2014.03 |
117 | 117 | * @category Developer |
118 | 118 | */ |
119 | - $decorators = $config->get( 'controller/frontend/common/decorators/default', [] ); |
|
120 | - $excludes = $config->get( 'controller/frontend/' . $domain . '/decorators/excludes', [] ); |
|
119 | + $decorators = $config->get('controller/frontend/common/decorators/default', []); |
|
120 | + $excludes = $config->get('controller/frontend/' . $domain . '/decorators/excludes', []); |
|
121 | 121 | |
122 | - foreach( $decorators as $key => $name ) |
|
122 | + foreach ($decorators as $key => $name) |
|
123 | 123 | { |
124 | - if( in_array( $name, $excludes ) ) { |
|
125 | - unset( $decorators[$key] ); |
|
124 | + if (in_array($name, $excludes)) { |
|
125 | + unset($decorators[$key]); |
|
126 | 126 | } |
127 | 127 | } |
128 | 128 | |
129 | 129 | $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; |
130 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
130 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
131 | 131 | |
132 | 132 | $classprefix = '\\Aimeos\\Controller\\Frontend\\Common\\Decorator\\'; |
133 | - $decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/global', [] ); |
|
134 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
133 | + $decorators = $config->get('controller/frontend/' . $domain . '/decorators/global', []); |
|
134 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
135 | 135 | |
136 | - $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst( $localClass ) . '\\Decorator\\'; |
|
137 | - $decorators = $config->get( 'controller/frontend/' . $domain . '/decorators/local', [] ); |
|
138 | - $controller = self::addDecorators( $context, $controller, $decorators, $classprefix ); |
|
136 | + $classprefix = '\\Aimeos\\Controller\\Frontend\\' . ucfirst($localClass) . '\\Decorator\\'; |
|
137 | + $decorators = $config->get('controller/frontend/' . $domain . '/decorators/local', []); |
|
138 | + $controller = self::addDecorators($context, $controller, $decorators, $classprefix); |
|
139 | 139 | |
140 | 140 | return $controller; |
141 | 141 | } |
@@ -149,20 +149,20 @@ discard block |
||
149 | 149 | * @param string $interface Name of the controller interface |
150 | 150 | * @return \Aimeos\Controller\Frontend\Common\Iface Controller object |
151 | 151 | */ |
152 | - protected static function createControllerBase( \Aimeos\MShop\Context\Item\Iface $context, $classname, $interface ) |
|
152 | + protected static function createControllerBase(\Aimeos\MShop\Context\Item\Iface $context, $classname, $interface) |
|
153 | 153 | { |
154 | - if( isset( self::$objects[$classname] ) ) { |
|
154 | + if (isset(self::$objects[$classname])) { |
|
155 | 155 | return self::$objects[$classname]; |
156 | 156 | } |
157 | 157 | |
158 | - if( class_exists( $classname ) === false ) { |
|
159 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $classname ) ); |
|
158 | + if (class_exists($classname) === false) { |
|
159 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $classname)); |
|
160 | 160 | } |
161 | 161 | |
162 | - $controller = new $classname( $context ); |
|
162 | + $controller = new $classname($context); |
|
163 | 163 | |
164 | - if( !( $controller instanceof $interface ) ) { |
|
165 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" does not implement interface "%2$s"', $classname, $interface ) ); |
|
164 | + if (!($controller instanceof $interface)) { |
|
165 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" does not implement interface "%2$s"', $classname, $interface)); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | return $controller; |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
37 | 37 | * @since 2017.03 |
38 | 38 | */ |
39 | - public function getItem( $id, array $domains = [] ); |
|
39 | + public function getItem($id, array $domains = []); |
|
40 | 40 | |
41 | 41 | |
42 | 42 | /** |
@@ -48,5 +48,5 @@ discard block |
||
48 | 48 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
49 | 49 | * @since 2017.03 |
50 | 50 | */ |
51 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ); |
|
51 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null); |
|
52 | 52 | } |
@@ -31,15 +31,15 @@ discard block |
||
31 | 31 | public function createFilter() |
32 | 32 | { |
33 | 33 | $context = $this->getContext(); |
34 | - $filter = \Aimeos\MShop\Factory::createManager( $context, 'locale' )->createSearch( true ); |
|
34 | + $filter = \Aimeos\MShop\Factory::createManager($context, 'locale')->createSearch(true); |
|
35 | 35 | |
36 | 36 | $expr = array( |
37 | - $filter->compare( '==', 'locale.siteid', $context->getLocale()->getSitePath() ), |
|
37 | + $filter->compare('==', 'locale.siteid', $context->getLocale()->getSitePath()), |
|
38 | 38 | $filter->getConditions(), |
39 | 39 | ); |
40 | 40 | |
41 | - $filter->setConditions( $filter->combine( '&&', $expr ) ); |
|
42 | - $filter->setSortations( array( $filter->sort( '+', 'locale.position' ) ) ); |
|
41 | + $filter->setConditions($filter->combine('&&', $expr)); |
|
42 | + $filter->setSortations(array($filter->sort('+', 'locale.position'))); |
|
43 | 43 | |
44 | 44 | return $filter; |
45 | 45 | } |
@@ -53,9 +53,9 @@ discard block |
||
53 | 53 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
54 | 54 | * @since 2017.03 |
55 | 55 | */ |
56 | - public function getItem( $id, array $domains = [] ) |
|
56 | + public function getItem($id, array $domains = []) |
|
57 | 57 | { |
58 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->getItem( $id, $domains, true ); |
|
58 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale')->getItem($id, $domains, true); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | |
@@ -68,8 +68,8 @@ discard block |
||
68 | 68 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
69 | 69 | * @since 2017.03 |
70 | 70 | */ |
71 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ) |
|
71 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null) |
|
72 | 72 | { |
73 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'locale' )->searchItems( $filter, $domains, $total ); |
|
73 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'locale')->searchItems($filter, $domains, $total); |
|
74 | 74 | } |
75 | 75 | } |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * @param integer $id Context ID the objects have been created with (string of \Aimeos\MShop\Context\Item\Iface) |
31 | 31 | * @param string $path Path describing the controller to clear, e.g. "basket" |
32 | 32 | */ |
33 | - static public function clear( $id = null, $path = null ) |
|
33 | + static public function clear($id = null, $path = null) |
|
34 | 34 | { |
35 | - if( $id !== null ) |
|
35 | + if ($id !== null) |
|
36 | 36 | { |
37 | - if( $path !== null ) { |
|
37 | + if ($path !== null) { |
|
38 | 38 | self::$controllers[$id][$path] = null; |
39 | 39 | } else { |
40 | 40 | self::$controllers[$id] = []; |
@@ -62,37 +62,37 @@ discard block |
||
62 | 62 | * @return \Aimeos\Controller\Frontend\Iface New frontend controller |
63 | 63 | * @throws \Aimeos\Controller\Frontend\Exception If the given path is invalid or the manager wasn't found |
64 | 64 | */ |
65 | - static public function createController( \Aimeos\MShop\Context\Item\Iface $context, $path ) |
|
65 | + static public function createController(\Aimeos\MShop\Context\Item\Iface $context, $path) |
|
66 | 66 | { |
67 | - if( empty( $path ) ) { |
|
68 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Controller path is empty' ) ); |
|
67 | + if (empty($path)) { |
|
68 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Controller path is empty')); |
|
69 | 69 | } |
70 | 70 | |
71 | 71 | $id = (string) $context; |
72 | 72 | |
73 | - if( self::$cache === false || !isset( self::$controllers[$id][$path] ) ) |
|
73 | + if (self::$cache === false || !isset(self::$controllers[$id][$path])) |
|
74 | 74 | { |
75 | - $parts = explode( '/', $path ); |
|
75 | + $parts = explode('/', $path); |
|
76 | 76 | |
77 | - foreach( $parts as $key => $part ) |
|
77 | + foreach ($parts as $key => $part) |
|
78 | 78 | { |
79 | - if( ctype_alnum( $part ) === false ) { |
|
80 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid characters in controller name "%1$s" in "%2$s"', $part, $path ) ); |
|
79 | + if (ctype_alnum($part) === false) { |
|
80 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid characters in controller name "%1$s" in "%2$s"', $part, $path)); |
|
81 | 81 | } |
82 | 82 | |
83 | - $parts[$key] = ucwords( $part ); |
|
83 | + $parts[$key] = ucwords($part); |
|
84 | 84 | } |
85 | 85 | |
86 | - $factory = '\\Aimeos\\Controller\\Frontend\\' . join( '\\', $parts ) . '\\Factory'; |
|
86 | + $factory = '\\Aimeos\\Controller\\Frontend\\' . join('\\', $parts) . '\\Factory'; |
|
87 | 87 | |
88 | - if( class_exists( $factory ) === false ) { |
|
89 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Class "%1$s" not available', $factory ) ); |
|
88 | + if (class_exists($factory) === false) { |
|
89 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Class "%1$s" not available', $factory)); |
|
90 | 90 | } |
91 | 91 | |
92 | - $manager = call_user_func_array( array( $factory, 'createController' ), array( $context ) ); |
|
92 | + $manager = call_user_func_array(array($factory, 'createController'), array($context)); |
|
93 | 93 | |
94 | - if( $manager === false ) { |
|
95 | - throw new \Aimeos\Controller\Frontend\Exception( sprintf( 'Invalid factory "%1$s"', $factory ) ); |
|
94 | + if ($manager === false) { |
|
95 | + throw new \Aimeos\Controller\Frontend\Exception(sprintf('Invalid factory "%1$s"', $factory)); |
|
96 | 96 | } |
97 | 97 | |
98 | 98 | self::$controllers[$id][$path] = $manager; |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @param boolean $value True to enable caching, false to disable it. |
109 | 109 | * @return boolean Previous cache setting |
110 | 110 | */ |
111 | - static public function setCache( $value ) |
|
111 | + static public function setCache($value) |
|
112 | 112 | { |
113 | 113 | $old = self::$cache; |
114 | 114 | self::$cache = (boolean) $value; |
@@ -28,13 +28,13 @@ 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 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
33 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
34 | 34 | |
35 | 35 | $item = $manager->createItem(); |
36 | - $item->fromArray( $values ); |
|
37 | - $manager->saveItem( $item ); |
|
36 | + $item->fromArray($values); |
|
37 | + $manager->saveItem($item); |
|
38 | 38 | |
39 | 39 | return $item; |
40 | 40 | } |
@@ -45,13 +45,13 @@ discard block |
||
45 | 45 | * |
46 | 46 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
47 | 47 | */ |
48 | - public function createItem( array $values = [] ) |
|
48 | + public function createItem(array $values = []) |
|
49 | 49 | { |
50 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
50 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
51 | 51 | |
52 | 52 | $item = $manager->createItem(); |
53 | - $item->fromArray( $values ); |
|
54 | - $item->setStatus( 1 ); |
|
53 | + $item->fromArray($values); |
|
54 | + $item->setStatus(1); |
|
55 | 55 | |
56 | 56 | return $item; |
57 | 57 | } |
@@ -63,12 +63,12 @@ discard block |
||
63 | 63 | * @param string $id Unique customer ID |
64 | 64 | * @since 2017.04 |
65 | 65 | */ |
66 | - public function deleteItem( $id ) |
|
66 | + public function deleteItem($id) |
|
67 | 67 | { |
68 | - $this->checkUser( $id ); |
|
68 | + $this->checkUser($id); |
|
69 | 69 | |
70 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
71 | - $manager->deleteItem( $id ); |
|
70 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
71 | + $manager->deleteItem($id); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item |
81 | 81 | * @since 2017.04 |
82 | 82 | */ |
83 | - public function editItem( $id, array $values ) |
|
83 | + public function editItem($id, array $values) |
|
84 | 84 | { |
85 | - $this->checkUser( $id ); |
|
85 | + $this->checkUser($id); |
|
86 | 86 | |
87 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
87 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
88 | 88 | |
89 | - $item = $manager->getItem( $id, [], true ); |
|
90 | - $item->fromArray( $values ); |
|
91 | - $manager->saveItem( $item ); |
|
89 | + $item = $manager->getItem($id, [], true); |
|
90 | + $item->fromArray($values); |
|
91 | + $manager->saveItem($item); |
|
92 | 92 | |
93 | 93 | return $item; |
94 | 94 | } |
@@ -102,17 +102,17 @@ discard block |
||
102 | 102 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
103 | 103 | * @since 2017.04 |
104 | 104 | */ |
105 | - public function getItem( $id = null, array $domains = [] ) |
|
105 | + public function getItem($id = null, array $domains = []) |
|
106 | 106 | { |
107 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' ); |
|
107 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer'); |
|
108 | 108 | |
109 | - if( $id == null ) { |
|
110 | - return $manager->getItem( $this->getContext()->getUserId(), $domains, true ); |
|
109 | + if ($id == null) { |
|
110 | + return $manager->getItem($this->getContext()->getUserId(), $domains, true); |
|
111 | 111 | } |
112 | 112 | |
113 | - $this->checkUser( $id ); |
|
113 | + $this->checkUser($id); |
|
114 | 114 | |
115 | - return $manager->getItem( $id, $domains, true ); |
|
115 | + return $manager->getItem($id, $domains, true); |
|
116 | 116 | } |
117 | 117 | |
118 | 118 | |
@@ -126,9 +126,9 @@ discard block |
||
126 | 126 | * @return \Aimeos\MShop\Customer\Item\Iface Customer item including the referenced domains items |
127 | 127 | * @since 2017.04 |
128 | 128 | */ |
129 | - public function findItem( $code, array $domains = [] ) |
|
129 | + public function findItem($code, array $domains = []) |
|
130 | 130 | { |
131 | - return \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->findItem( $code, $domains ); |
|
131 | + return \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->findItem($code, $domains); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | |
@@ -137,9 +137,9 @@ discard block |
||
137 | 137 | * |
138 | 138 | * @param \Aimeos\MShop\Customer\Item\Iface Customer item |
139 | 139 | */ |
140 | - public function saveItem( \Aimeos\MShop\Customer\Item\Iface $item ) |
|
140 | + public function saveItem(\Aimeos\MShop\Customer\Item\Iface $item) |
|
141 | 141 | { |
142 | - \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer' )->saveItem( $item ); |
|
142 | + \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer')->saveItem($item); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
151 | 151 | * @since 2017.04 |
152 | 152 | */ |
153 | - public function addAddressItem( array $values ) |
|
153 | + public function addAddressItem(array $values) |
|
154 | 154 | { |
155 | 155 | $context = $this->getContext(); |
156 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
156 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
157 | 157 | |
158 | 158 | $item = $manager->createItem(); |
159 | - $item->fromArray( $values ); |
|
160 | - $item->setParentId( $context->getUserId() ); |
|
161 | - $manager->saveItem( $item ); |
|
159 | + $item->fromArray($values); |
|
160 | + $item->setParentId($context->getUserId()); |
|
161 | + $manager->saveItem($item); |
|
162 | 162 | |
163 | 163 | return $item; |
164 | 164 | } |
@@ -169,14 +169,14 @@ discard block |
||
169 | 169 | * |
170 | 170 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
171 | 171 | */ |
172 | - public function createAddressItem( array $values = [] ) |
|
172 | + public function createAddressItem(array $values = []) |
|
173 | 173 | { |
174 | 174 | $context = $this->getContext(); |
175 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer/address' ); |
|
175 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer/address'); |
|
176 | 176 | |
177 | 177 | $item = $manager->createItem(); |
178 | - $item->fromArray( $values ); |
|
179 | - $item->setParentId( $context->getUserId() ); |
|
178 | + $item->fromArray($values); |
|
179 | + $item->setParentId($context->getUserId()); |
|
180 | 180 | |
181 | 181 | return $item; |
182 | 182 | } |
@@ -188,13 +188,13 @@ discard block |
||
188 | 188 | * @param string $id Unique customer address ID |
189 | 189 | * @since 2017.04 |
190 | 190 | */ |
191 | - public function deleteAddressItem( $id ) |
|
191 | + public function deleteAddressItem($id) |
|
192 | 192 | { |
193 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
193 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
194 | 194 | |
195 | - $this->checkUser( $manager->getItem( $id, [], true )->getParentId() ); |
|
195 | + $this->checkUser($manager->getItem($id, [], true)->getParentId()); |
|
196 | 196 | |
197 | - $manager->deleteItem( $id ); |
|
197 | + $manager->deleteItem($id); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -206,15 +206,15 @@ discard block |
||
206 | 206 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
207 | 207 | * @since 2017.04 |
208 | 208 | */ |
209 | - public function editAddressItem( $id, array $values ) |
|
209 | + public function editAddressItem($id, array $values) |
|
210 | 210 | { |
211 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
211 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
212 | 212 | |
213 | - $item = $manager->getItem( $id, [], true ); |
|
214 | - $this->checkUser( $item->getParentId() ); |
|
213 | + $item = $manager->getItem($id, [], true); |
|
214 | + $this->checkUser($item->getParentId()); |
|
215 | 215 | |
216 | - $item->fromArray( $values ); |
|
217 | - $manager->saveItem( $item ); |
|
216 | + $item->fromArray($values); |
|
217 | + $manager->saveItem($item); |
|
218 | 218 | |
219 | 219 | return $item; |
220 | 220 | } |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * @return \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
228 | 228 | * @since 2017.04 |
229 | 229 | */ |
230 | - public function getAddressItem( $id ) |
|
230 | + public function getAddressItem($id) |
|
231 | 231 | { |
232 | - $manager = \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' ); |
|
233 | - $item = $manager->getItem( $id ); |
|
232 | + $manager = \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address'); |
|
233 | + $item = $manager->getItem($id); |
|
234 | 234 | |
235 | - $this->checkUser( $item->getParentId() ); |
|
235 | + $this->checkUser($item->getParentId()); |
|
236 | 236 | |
237 | 237 | return $item; |
238 | 238 | } |
@@ -243,9 +243,9 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param \Aimeos\MShop\Customer\Item\Address\Iface Customer address item |
245 | 245 | */ |
246 | - public function saveAddressItem( \Aimeos\MShop\Customer\Item\Address\Iface $item ) |
|
246 | + public function saveAddressItem(\Aimeos\MShop\Customer\Item\Address\Iface $item) |
|
247 | 247 | { |
248 | - \Aimeos\MShop\Factory::createManager( $this->getContext(), 'customer/address' )->saveItem( $item ); |
|
248 | + \Aimeos\MShop\Factory::createManager($this->getContext(), 'customer/address')->saveItem($item); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | |
@@ -255,12 +255,12 @@ discard block |
||
255 | 255 | * @param string $id Unique customer ID |
256 | 256 | * @throws \Aimeos\Controller\Frontend\Customer\Exception If access isn't allowed |
257 | 257 | */ |
258 | - protected function checkUser( $id ) |
|
258 | + protected function checkUser($id) |
|
259 | 259 | { |
260 | - if( $id != $this->getContext()->getUserId() ) |
|
260 | + if ($id != $this->getContext()->getUserId()) |
|
261 | 261 | { |
262 | - $msg = sprintf( 'Not allowed to access customer data for ID "%1$s"', $id ); |
|
263 | - throw new \Aimeos\Controller\Frontend\Customer\Exception( $msg ); |
|
262 | + $msg = sprintf('Not allowed to access customer data for ID "%1$s"', $id); |
|
263 | + throw new \Aimeos\Controller\Frontend\Customer\Exception($msg); |
|
264 | 264 | } |
265 | 265 | } |
266 | 266 | } |