@@ -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 | } |
@@ -30,18 +30,18 @@ discard block |
||
| 30 | 30 | * @param \Aimeos\Controller\Frontend\Iface $controller Controller object |
| 31 | 31 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object with required objects |
| 32 | 32 | */ |
| 33 | - public function __construct( \Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 33 | + public function __construct(\Aimeos\Controller\Frontend\Iface $controller, \Aimeos\MShop\Context\Item\Iface $context) |
|
| 34 | 34 | { |
| 35 | 35 | $iface = '\Aimeos\Controller\Frontend\Locale\Iface'; |
| 36 | - if( !( $controller instanceof $iface ) ) |
|
| 36 | + if (!($controller instanceof $iface)) |
|
| 37 | 37 | { |
| 38 | - $msg = sprintf( 'Class "%1$s" does not implement interface "%2$s"', get_class( $controller ), $iface ); |
|
| 39 | - throw new \Aimeos\Controller\Frontend\Exception( $msg ); |
|
| 38 | + $msg = sprintf('Class "%1$s" does not implement interface "%2$s"', get_class($controller), $iface); |
|
| 39 | + throw new \Aimeos\Controller\Frontend\Exception($msg); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | $this->controller = $controller; |
| 43 | 43 | |
| 44 | - parent::__construct( $context ); |
|
| 44 | + parent::__construct($context); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | |
@@ -53,9 +53,9 @@ discard block |
||
| 53 | 53 | * @return mixed Returns the value of the called method |
| 54 | 54 | * @throws \Aimeos\Controller\Frontend\Exception If method call failed |
| 55 | 55 | */ |
| 56 | - public function __call( $name, array $param ) |
|
| 56 | + public function __call($name, array $param) |
|
| 57 | 57 | { |
| 58 | - return @call_user_func_array( array( $this->controller, $name ), $param ); |
|
| 58 | + return @call_user_func_array(array($this->controller, $name), $param); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | |
@@ -80,9 +80,9 @@ discard block |
||
| 80 | 80 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item including the referenced domains items |
| 81 | 81 | * @since 2017.03 |
| 82 | 82 | */ |
| 83 | - public function getItem( $id, array $domains = [] ) |
|
| 83 | + public function getItem($id, array $domains = []) |
|
| 84 | 84 | { |
| 85 | - return $this->controller->getItem( $id, $domains ); |
|
| 85 | + return $this->controller->getItem($id, $domains); |
|
| 86 | 86 | } |
| 87 | 87 | |
| 88 | 88 | |
@@ -95,9 +95,9 @@ discard block |
||
| 95 | 95 | * @return array Ordered list of locale items implementing \Aimeos\MShop\Locale\Item\Iface |
| 96 | 96 | * @since 2017.03 |
| 97 | 97 | */ |
| 98 | - public function searchItems( \Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null ) |
|
| 98 | + public function searchItems(\Aimeos\MW\Criteria\Iface $filter, array $domains = [], &$total = null) |
|
| 99 | 99 | { |
| 100 | - return $this->controller->searchItems( $filter, $domains, $total ); |
|
| 100 | + return $this->controller->searchItems($filter, $domains, $total); |
|
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | |
@@ -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; |