@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @param RequestStack $requestStack Current request stack |
| 35 | 35 | * @param Container $container Container object to access parameters |
| 36 | 36 | */ |
| 37 | - public function __construct( RequestStack $requestStack, Container $container ) |
|
| 37 | + public function __construct(RequestStack $requestStack, Container $container) |
|
| 38 | 38 | { |
| 39 | 39 | $this->requestStack = $requestStack; |
| 40 | 40 | $this->container = $container; |
@@ -47,52 +47,52 @@ discard block |
||
| 47 | 47 | * @param boolean $locale True to add locale object to context, false if not |
| 48 | 48 | * @return \Aimeos\MShop\Context\Item\Iface Context object |
| 49 | 49 | */ |
| 50 | - public function get( $locale = true ) |
|
| 50 | + public function get($locale = true) |
|
| 51 | 51 | { |
| 52 | - if( self::$context === null ) |
|
| 52 | + if (self::$context === null) |
|
| 53 | 53 | { |
| 54 | 54 | $context = new \Aimeos\MShop\Context\Item\Standard(); |
| 55 | 55 | |
| 56 | 56 | $config = $this->getConfig(); |
| 57 | - $context->setConfig( $config ); |
|
| 57 | + $context->setConfig($config); |
|
| 58 | 58 | |
| 59 | - $dbm = new \Aimeos\MW\DB\Manager\PDO( $config ); |
|
| 60 | - $context->setDatabaseManager( $dbm ); |
|
| 59 | + $dbm = new \Aimeos\MW\DB\Manager\PDO($config); |
|
| 60 | + $context->setDatabaseManager($dbm); |
|
| 61 | 61 | |
| 62 | - $fs = new \Aimeos\MW\Filesystem\Manager\Standard( $config ); |
|
| 63 | - $context->setFilesystemManager( $fs ); |
|
| 62 | + $fs = new \Aimeos\MW\Filesystem\Manager\Standard($config); |
|
| 63 | + $context->setFilesystemManager($fs); |
|
| 64 | 64 | |
| 65 | - $mq = new \Aimeos\MW\MQueue\Manager\Standard( $config ); |
|
| 66 | - $context->setMessageQueueManager( $mq ); |
|
| 65 | + $mq = new \Aimeos\MW\MQueue\Manager\Standard($config); |
|
| 66 | + $context->setMessageQueueManager($mq); |
|
| 67 | 67 | |
| 68 | 68 | $container = $this->container; |
| 69 | - $mail = new \Aimeos\MW\Mail\Swift( function() use ( $container) { return $container->get( 'mailer' ); } ); |
|
| 70 | - $context->setMail( $mail ); |
|
| 69 | + $mail = new \Aimeos\MW\Mail\Swift(function() use ($container) { return $container->get('mailer'); } ); |
|
| 70 | + $context->setMail($mail); |
|
| 71 | 71 | |
| 72 | - $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager( $context ); |
|
| 73 | - $context->setLogger( $logger ); |
|
| 72 | + $logger = \Aimeos\MAdmin\Log\Manager\Factory::createManager($context); |
|
| 73 | + $context->setLogger($logger); |
|
| 74 | 74 | |
| 75 | - $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard( $context ); |
|
| 76 | - $context->setCache( $cache ); |
|
| 75 | + $cache = new \Aimeos\MAdmin\Cache\Proxy\Standard($context); |
|
| 76 | + $context->setCache($cache); |
|
| 77 | 77 | |
| 78 | 78 | self::$context = $context; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | $context = self::$context; |
| 82 | 82 | |
| 83 | - if( $locale === true ) |
|
| 83 | + if ($locale === true) |
|
| 84 | 84 | { |
| 85 | - $localeItem = $this->getLocale( $context ); |
|
| 85 | + $localeItem = $this->getLocale($context); |
|
| 86 | 86 | $langid = $localeItem->getLanguageId(); |
| 87 | 87 | |
| 88 | - $context->setLocale( $localeItem ); |
|
| 89 | - $context->setI18n( $this->container->get('aimeos_i18n')->get( array( $langid ) ) ); |
|
| 88 | + $context->setLocale($localeItem); |
|
| 89 | + $context->setI18n($this->container->get('aimeos_i18n')->get(array($langid))); |
|
| 90 | 90 | } |
| 91 | 91 | |
| 92 | - $session = new \Aimeos\MW\Session\Symfony2( $this->container->get( 'session' ) ); |
|
| 93 | - $context->setSession( $session ); |
|
| 92 | + $session = new \Aimeos\MW\Session\Symfony2($this->container->get('session')); |
|
| 93 | + $context->setSession($session); |
|
| 94 | 94 | |
| 95 | - $this->addUser( $context ); |
|
| 95 | + $this->addUser($context); |
|
| 96 | 96 | |
| 97 | 97 | return $context; |
| 98 | 98 | } |
@@ -103,39 +103,39 @@ discard block |
||
| 103 | 103 | * |
| 104 | 104 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 105 | 105 | */ |
| 106 | - protected function addUser( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 106 | + protected function addUser(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 107 | 107 | { |
| 108 | 108 | $token = null; |
| 109 | 109 | $username = ''; |
| 110 | 110 | |
| 111 | - if( $this->container->has( 'security.token_storage' ) ) { |
|
| 112 | - $token = $this->container->get( 'security.token_storage' )->getToken(); |
|
| 111 | + if ($this->container->has('security.token_storage')) { |
|
| 112 | + $token = $this->container->get('security.token_storage')->getToken(); |
|
| 113 | 113 | } |
| 114 | - else if( $this->container->has( 'security.context' ) ) { |
|
| 115 | - $token = $this->container->get( 'security.context' )->getToken(); |
|
| 114 | + else if ($this->container->has('security.context')) { |
|
| 115 | + $token = $this->container->get('security.context')->getToken(); |
|
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - if( is_object( $token ) ) |
|
| 118 | + if (is_object($token)) |
|
| 119 | 119 | { |
| 120 | - if( method_exists( $token->getUser(), 'getId' ) ) |
|
| 120 | + if (method_exists($token->getUser(), 'getId')) |
|
| 121 | 121 | { |
| 122 | 122 | $userid = $token->getUser()->getId(); |
| 123 | - $context->setUserId( $userid ); |
|
| 124 | - $context->setGroupIds( function() use ( $context, $userid ) |
|
| 123 | + $context->setUserId($userid); |
|
| 124 | + $context->setGroupIds(function() use ($context, $userid) |
|
| 125 | 125 | { |
| 126 | - $manager = \Aimeos\MShop\Factory::createManager( $context, 'customer' ); |
|
| 127 | - return $manager->getItem( $userid, array( 'customer/group' ) )->getGroups(); |
|
| 126 | + $manager = \Aimeos\MShop\Factory::createManager($context, 'customer'); |
|
| 127 | + return $manager->getItem($userid, array('customer/group'))->getGroups(); |
|
| 128 | 128 | } ); |
| 129 | 129 | } |
| 130 | 130 | |
| 131 | - if( is_object( $token->getUser() ) ) { |
|
| 132 | - $username = $token->getUser()->getUsername(); |
|
| 131 | + if (is_object($token->getUser())) { |
|
| 132 | + $username = $token->getUser()->getUsername(); |
|
| 133 | 133 | } else { |
| 134 | 134 | $username = $token->getUser(); |
| 135 | 135 | } |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - $context->setEditor( $username ); |
|
| 138 | + $context->setEditor($username); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | |
@@ -146,27 +146,27 @@ discard block |
||
| 146 | 146 | */ |
| 147 | 147 | protected function getConfig() |
| 148 | 148 | { |
| 149 | - $configPaths = $this->container->get('aimeos')->get()->getConfigPaths( 'mysql' ); |
|
| 149 | + $configPaths = $this->container->get('aimeos')->get()->getConfigPaths('mysql'); |
|
| 150 | 150 | |
| 151 | - $conf = new \Aimeos\MW\Config\PHPArray( array(), $configPaths ); |
|
| 151 | + $conf = new \Aimeos\MW\Config\PHPArray(array(), $configPaths); |
|
| 152 | 152 | |
| 153 | - $apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' ); |
|
| 154 | - $prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' ); |
|
| 153 | + $apc = (bool) $this->container->getParameter('aimeos_shop.apc_enable'); |
|
| 154 | + $prefix = $this->container->getParameter('aimeos_shop.apc_prefix'); |
|
| 155 | 155 | |
| 156 | - if( function_exists( 'apc_store' ) === true && $apc === true ) { |
|
| 157 | - $conf = new \Aimeos\MW\Config\Decorator\APC( $conf, $prefix ); |
|
| 156 | + if (function_exists('apc_store') === true && $apc === true) { |
|
| 157 | + $conf = new \Aimeos\MW\Config\Decorator\APC($conf, $prefix); |
|
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | $local = array( |
| 161 | - 'admin' => $this->container->getParameter( 'aimeos_shop.admin' ), |
|
| 162 | - 'client' => $this->container->getParameter( 'aimeos_shop.client' ), |
|
| 163 | - 'controller' => $this->container->getParameter( 'aimeos_shop.controller' ), |
|
| 164 | - 'madmin' => $this->container->getParameter( 'aimeos_shop.madmin' ), |
|
| 165 | - 'mshop' => $this->container->getParameter( 'aimeos_shop.mshop' ), |
|
| 166 | - 'resource' => $this->container->getParameter( 'aimeos_shop.resource' ), |
|
| 161 | + 'admin' => $this->container->getParameter('aimeos_shop.admin'), |
|
| 162 | + 'client' => $this->container->getParameter('aimeos_shop.client'), |
|
| 163 | + 'controller' => $this->container->getParameter('aimeos_shop.controller'), |
|
| 164 | + 'madmin' => $this->container->getParameter('aimeos_shop.madmin'), |
|
| 165 | + 'mshop' => $this->container->getParameter('aimeos_shop.mshop'), |
|
| 166 | + 'resource' => $this->container->getParameter('aimeos_shop.resource'), |
|
| 167 | 167 | ); |
| 168 | 168 | |
| 169 | - return new \Aimeos\MW\Config\Decorator\Memory( $conf, $local ); |
|
| 169 | + return new \Aimeos\MW\Config\Decorator\Memory($conf, $local); |
|
| 170 | 170 | } |
| 171 | 171 | |
| 172 | 172 | |
@@ -176,19 +176,19 @@ discard block |
||
| 176 | 176 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 177 | 177 | * @return \Aimeos\MShop\Locale\Item\Iface Locale item object |
| 178 | 178 | */ |
| 179 | - protected function getLocale( \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 179 | + protected function getLocale(\Aimeos\MShop\Context\Item\Iface $context) |
|
| 180 | 180 | { |
| 181 | - if( $this->locale === null ) |
|
| 181 | + if ($this->locale === null) |
|
| 182 | 182 | { |
| 183 | - $status = $this->container->getParameter( 'aimeos_shop.disable_sites' ); |
|
| 183 | + $status = $this->container->getParameter('aimeos_shop.disable_sites'); |
|
| 184 | 184 | $request = $this->requestStack->getMasterRequest(); |
| 185 | 185 | |
| 186 | - $site = $request->attributes->get( 'site', $request->query->get( 'site', 'default' ) ); |
|
| 187 | - $currency = $request->attributes->get( 'currency', $request->query->get( 'currency', '' ) ); |
|
| 188 | - $lang = $request->attributes->get( 'locale', $request->query->get( 'locale', '' ) ); |
|
| 186 | + $site = $request->attributes->get('site', $request->query->get('site', 'default')); |
|
| 187 | + $currency = $request->attributes->get('currency', $request->query->get('currency', '')); |
|
| 188 | + $lang = $request->attributes->get('locale', $request->query->get('locale', '')); |
|
| 189 | 189 | |
| 190 | - $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context ); |
|
| 191 | - $this->locale = $localeManager->bootstrap( $site, $lang, $currency, $status ); |
|
| 190 | + $localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context); |
|
| 191 | + $this->locale = $localeManager->bootstrap($site, $lang, $currency, $status); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | return $this->locale; |