@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | * @param RequestStack $requestStack Current request stack |
| 33 | 33 | * @param Container $container Container object to access parameters |
| 34 | 34 | */ |
| 35 | - public function __construct( RequestStack $requestStack, Container $container ) |
|
| 35 | + public function __construct(RequestStack $requestStack, Container $container) |
|
| 36 | 36 | { |
| 37 | 37 | $this->requestStack = $requestStack; |
| 38 | 38 | $this->container = $container; |
@@ -47,21 +47,21 @@ discard block |
||
| 47 | 47 | * @param string|null $locale Code of the current language or null for no translation |
| 48 | 48 | * @return \Aimeos\MW\View\Iface View object |
| 49 | 49 | */ |
| 50 | - public function create( \Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $locale = null ) |
|
| 50 | + public function create(\Aimeos\MShop\Context\Item\Iface $context, array $templatePaths, $locale = null) |
|
| 51 | 51 | { |
| 52 | - $engine = new \Aimeos\MW\View\Engine\Twig( $this->container->get( 'twig' ) ); |
|
| 53 | - $view = new \Aimeos\MW\View\Standard( $templatePaths, array( '.html.twig' => $engine ) ); |
|
| 52 | + $engine = new \Aimeos\MW\View\Engine\Twig($this->container->get('twig')); |
|
| 53 | + $view = new \Aimeos\MW\View\Standard($templatePaths, array('.html.twig' => $engine)); |
|
| 54 | 54 | $config = $context->getConfig(); |
| 55 | 55 | |
| 56 | - $this->addCsrf( $view ); |
|
| 57 | - $this->addAccess( $view, $context ); |
|
| 58 | - $this->addConfig( $view, $config ); |
|
| 59 | - $this->addNumber( $view, $config ); |
|
| 60 | - $this->addParam( $view ); |
|
| 61 | - $this->addRequest( $view ); |
|
| 62 | - $this->addResponse( $view ); |
|
| 63 | - $this->addTranslate( $view, $locale ); |
|
| 64 | - $this->addUrl( $view ); |
|
| 56 | + $this->addCsrf($view); |
|
| 57 | + $this->addAccess($view, $context); |
|
| 58 | + $this->addConfig($view, $config); |
|
| 59 | + $this->addNumber($view, $config); |
|
| 60 | + $this->addParam($view); |
|
| 61 | + $this->addRequest($view); |
|
| 62 | + $this->addResponse($view); |
|
| 63 | + $this->addTranslate($view, $locale); |
|
| 64 | + $this->addUrl($view); |
|
| 65 | 65 | |
| 66 | 66 | return $view; |
| 67 | 67 | } |
@@ -74,26 +74,26 @@ discard block |
||
| 74 | 74 | * @param \Aimeos\MShop\Context\Item\Iface $context Context object |
| 75 | 75 | * @return \Aimeos\MW\View\Iface Modified view object |
| 76 | 76 | */ |
| 77 | - protected function addAccess( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Context\Item\Iface $context ) |
|
| 77 | + protected function addAccess(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Context\Item\Iface $context) |
|
| 78 | 78 | { |
| 79 | 79 | $container = $this->container; |
| 80 | - $token = $this->container->get( 'security.token_storage' )->getToken(); |
|
| 80 | + $token = $this->container->get('security.token_storage')->getToken(); |
|
| 81 | 81 | |
| 82 | - if( is_object( $token ) && is_object( $token->getUser() ) |
|
| 83 | - && in_array( 'ROLE_ADMIN', (array) $token->getUser()->getRoles() ) ) |
|
| 82 | + if (is_object($token) && is_object($token->getUser()) |
|
| 83 | + && in_array('ROLE_ADMIN', (array) $token->getUser()->getRoles())) |
|
| 84 | 84 | { |
| 85 | - $helper = new \Aimeos\MW\View\Helper\Access\All( $view ); |
|
| 85 | + $helper = new \Aimeos\MW\View\Helper\Access\All($view); |
|
| 86 | 86 | } |
| 87 | 87 | else |
| 88 | 88 | { |
| 89 | - $fcn = function() use ( $container, $context ) { |
|
| 90 | - return $container->get( 'aimeos_support' )->getGroups( $context ); |
|
| 89 | + $fcn = function() use ($container, $context) { |
|
| 90 | + return $container->get('aimeos_support')->getGroups($context); |
|
| 91 | 91 | }; |
| 92 | 92 | |
| 93 | - $helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $fcn ); |
|
| 93 | + $helper = new \Aimeos\MW\View\Helper\Access\Standard($view, $fcn); |
|
| 94 | 94 | } |
| 95 | 95 | |
| 96 | - $view->addHelper( 'access', $helper ); |
|
| 96 | + $view->addHelper('access', $helper); |
|
| 97 | 97 | |
| 98 | 98 | return $view; |
| 99 | 99 | } |
@@ -106,11 +106,11 @@ discard block |
||
| 106 | 106 | * @param \Aimeos\MW\Config\Iface $config Configuration object |
| 107 | 107 | * @return \Aimeos\MW\View\Iface Modified view object |
| 108 | 108 | */ |
| 109 | - protected function addConfig( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config ) |
|
| 109 | + protected function addConfig(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config) |
|
| 110 | 110 | { |
| 111 | - $config = new \Aimeos\MW\Config\Decorator\Protect( clone $config, array( 'admin', 'client' ) ); |
|
| 112 | - $helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config ); |
|
| 113 | - $view->addHelper( 'config', $helper ); |
|
| 111 | + $config = new \Aimeos\MW\Config\Decorator\Protect(clone $config, array('admin', 'client')); |
|
| 112 | + $helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config); |
|
| 113 | + $view->addHelper('config', $helper); |
|
| 114 | 114 | |
| 115 | 115 | return $view; |
| 116 | 116 | } |
@@ -122,11 +122,11 @@ discard block |
||
| 122 | 122 | * @param \Aimeos\MW\View\Iface $view View object |
| 123 | 123 | * @return \Aimeos\MW\View\Iface Modified view object |
| 124 | 124 | */ |
| 125 | - protected function addCsrf( \Aimeos\MW\View\Iface $view ) |
|
| 125 | + protected function addCsrf(\Aimeos\MW\View\Iface $view) |
|
| 126 | 126 | { |
| 127 | - $token = $this->container->get( 'security.csrf.token_manager' )->getToken( '_token' ); |
|
| 128 | - $helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_token', $token->getValue() ); |
|
| 129 | - $view->addHelper( 'csrf', $helper ); |
|
| 127 | + $token = $this->container->get('security.csrf.token_manager')->getToken('_token'); |
|
| 128 | + $helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', $token->getValue()); |
|
| 129 | + $view->addHelper('csrf', $helper); |
|
| 130 | 130 | |
| 131 | 131 | return $view; |
| 132 | 132 | } |
@@ -139,14 +139,14 @@ discard block |
||
| 139 | 139 | * @param \Aimeos\MW\Config\Iface $config Configuration object |
| 140 | 140 | * @return \Aimeos\MW\View\Iface Modified view object |
| 141 | 141 | */ |
| 142 | - protected function addNumber( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config ) |
|
| 142 | + protected function addNumber(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config) |
|
| 143 | 143 | { |
| 144 | - $sepDec = $config->get( 'client/html/common/format/separatorDecimal', '.' ); |
|
| 145 | - $sep1000 = $config->get( 'client/html/common/format/separator1000', ' ' ); |
|
| 146 | - $decimals = $config->get( 'client/html/common/format/decimals', 2 ); |
|
| 144 | + $sepDec = $config->get('client/html/common/format/separatorDecimal', '.'); |
|
| 145 | + $sep1000 = $config->get('client/html/common/format/separator1000', ' '); |
|
| 146 | + $decimals = $config->get('client/html/common/format/decimals', 2); |
|
| 147 | 147 | |
| 148 | - $helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000, $decimals ); |
|
| 149 | - $view->addHelper( 'number', $helper ); |
|
| 148 | + $helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000, $decimals); |
|
| 149 | + $view->addHelper('number', $helper); |
|
| 150 | 150 | |
| 151 | 151 | return $view; |
| 152 | 152 | } |
@@ -158,17 +158,17 @@ discard block |
||
| 158 | 158 | * @param \Aimeos\MW\View\Iface $view View object |
| 159 | 159 | * @return \Aimeos\MW\View\Iface Modified view object |
| 160 | 160 | */ |
| 161 | - protected function addParam( \Aimeos\MW\View\Iface $view ) |
|
| 161 | + protected function addParam(\Aimeos\MW\View\Iface $view) |
|
| 162 | 162 | { |
| 163 | 163 | $params = array(); |
| 164 | 164 | $request = $this->requestStack->getMasterRequest(); |
| 165 | 165 | |
| 166 | - if( $request !== null ) { |
|
| 167 | - $params = $request->request->all() + $request->query->all() + $request->attributes->get( '_route_params' ); |
|
| 166 | + if ($request !== null) { |
|
| 167 | + $params = $request->request->all() + $request->query->all() + $request->attributes->get('_route_params'); |
|
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - $helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params ); |
|
| 171 | - $view->addHelper( 'param', $helper ); |
|
| 170 | + $helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params); |
|
| 171 | + $view->addHelper('param', $helper); |
|
| 172 | 172 | |
| 173 | 173 | return $view; |
| 174 | 174 | } |
@@ -180,14 +180,14 @@ discard block |
||
| 180 | 180 | * @param \Aimeos\MW\View\Iface $view View object |
| 181 | 181 | * @return \Aimeos\MW\View\Iface Modified view object |
| 182 | 182 | */ |
| 183 | - protected function addRequest( \Aimeos\MW\View\Iface $view ) |
|
| 183 | + protected function addRequest(\Aimeos\MW\View\Iface $view) |
|
| 184 | 184 | { |
| 185 | 185 | $request = $this->requestStack->getMasterRequest(); |
| 186 | 186 | |
| 187 | - if( $request !== null ) |
|
| 187 | + if ($request !== null) |
|
| 188 | 188 | { |
| 189 | - $helper = new \Aimeos\MW\View\Helper\Request\Symfony2( $view, $request ); |
|
| 190 | - $view->addHelper( 'request', $helper ); |
|
| 189 | + $helper = new \Aimeos\MW\View\Helper\Request\Symfony2($view, $request); |
|
| 190 | + $view->addHelper('request', $helper); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | return $view; |
@@ -200,10 +200,10 @@ discard block |
||
| 200 | 200 | * @param \Aimeos\MW\View\Iface $view View object |
| 201 | 201 | * @return \Aimeos\MW\View\Iface Modified view object |
| 202 | 202 | */ |
| 203 | - protected function addResponse( \Aimeos\MW\View\Iface $view ) |
|
| 203 | + protected function addResponse(\Aimeos\MW\View\Iface $view) |
|
| 204 | 204 | { |
| 205 | - $helper = new \Aimeos\MW\View\Helper\Response\Symfony2( $view ); |
|
| 206 | - $view->addHelper( 'response', $helper ); |
|
| 205 | + $helper = new \Aimeos\MW\View\Helper\Response\Symfony2($view); |
|
| 206 | + $view->addHelper('response', $helper); |
|
| 207 | 207 | |
| 208 | 208 | return $view; |
| 209 | 209 | } |
@@ -216,20 +216,20 @@ discard block |
||
| 216 | 216 | * @param string|null $locale ISO language code, e.g. "de" or "de_CH" |
| 217 | 217 | * @return \Aimeos\MW\View\Iface Modified view object |
| 218 | 218 | */ |
| 219 | - protected function addTranslate( \Aimeos\MW\View\Iface $view, $locale ) |
|
| 219 | + protected function addTranslate(\Aimeos\MW\View\Iface $view, $locale) |
|
| 220 | 220 | { |
| 221 | - if( $locale !== null ) |
|
| 221 | + if ($locale !== null) |
|
| 222 | 222 | { |
| 223 | - $i18n = $this->container->get( 'aimeos_i18n' )->get( array( $locale ) ); |
|
| 223 | + $i18n = $this->container->get('aimeos_i18n')->get(array($locale)); |
|
| 224 | 224 | $translation = $i18n[$locale]; |
| 225 | 225 | } |
| 226 | 226 | else |
| 227 | 227 | { |
| 228 | - $translation = new \Aimeos\MW\Translation\None( 'en' ); |
|
| 228 | + $translation = new \Aimeos\MW\Translation\None('en'); |
|
| 229 | 229 | } |
| 230 | 230 | |
| 231 | - $helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation ); |
|
| 232 | - $view->addHelper( 'translate', $helper ); |
|
| 231 | + $helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation); |
|
| 232 | + $view->addHelper('translate', $helper); |
|
| 233 | 233 | |
| 234 | 234 | return $view; |
| 235 | 235 | } |
@@ -241,30 +241,30 @@ discard block |
||
| 241 | 241 | * @param \Aimeos\MW\View\Iface $view View object |
| 242 | 242 | * @return \Aimeos\MW\View\Iface Modified view object |
| 243 | 243 | */ |
| 244 | - protected function addUrl( \Aimeos\MW\View\Iface $view ) |
|
| 244 | + protected function addUrl(\Aimeos\MW\View\Iface $view) |
|
| 245 | 245 | { |
| 246 | 246 | $fixed = array(); |
| 247 | 247 | $request = $this->requestStack->getMasterRequest(); |
| 248 | 248 | |
| 249 | - if( $request !== null ) |
|
| 249 | + if ($request !== null) |
|
| 250 | 250 | { |
| 251 | 251 | $attr = $request->attributes; |
| 252 | 252 | |
| 253 | - if( ( $site = $attr->get( 'site' ) ) !== null ) { |
|
| 253 | + if (($site = $attr->get('site')) !== null) { |
|
| 254 | 254 | $fixed['site'] = $site; |
| 255 | 255 | } |
| 256 | 256 | |
| 257 | - if( ( $lang = $attr->get( 'locale' ) ) !== null ) { |
|
| 257 | + if (($lang = $attr->get('locale')) !== null) { |
|
| 258 | 258 | $fixed['locale'] = $lang; |
| 259 | 259 | } |
| 260 | 260 | |
| 261 | - if( ( $currency = $attr->get( 'currency' ) ) !== null ) { |
|
| 261 | + if (($currency = $attr->get('currency')) !== null) { |
|
| 262 | 262 | $fixed['currency'] = $currency; |
| 263 | 263 | } |
| 264 | 264 | } |
| 265 | 265 | |
| 266 | - $helper = new \Aimeos\MW\View\Helper\Url\Symfony2( $view, $this->container->get( 'router' ), $fixed ); |
|
| 267 | - $view->addHelper( 'url', $helper ); |
|
| 266 | + $helper = new \Aimeos\MW\View\Helper\Url\Symfony2($view, $this->container->get('router'), $fixed); |
|
| 267 | + $view->addHelper('url', $helper); |
|
| 268 | 268 | |
| 269 | 269 | return $view; |
| 270 | 270 | } |