Completed
Push — master ( 8e6870...e49ab8 )
by Aimeos
02:23
created
Service/View.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
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,20 +47,20 @@  discard block
 block discarded – undo
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 52
 		$config = $context->getConfig();
53
-		$view = new \Aimeos\MW\View\Standard( $templatePaths );
54
-
55
-		$this->addCsrf( $view );
56
-		$this->addAccess( $view, $context );
57
-		$this->addConfig( $view, $config );
58
-		$this->addNumber( $view, $config );
59
-		$this->addParam( $view );
60
-		$this->addRequest( $view );
61
-		$this->addResponse( $view );
62
-		$this->addTranslate( $view, $locale );
63
-		$this->addUrl( $view );
53
+		$view = new \Aimeos\MW\View\Standard($templatePaths);
54
+
55
+		$this->addCsrf($view);
56
+		$this->addAccess($view, $context);
57
+		$this->addConfig($view, $config);
58
+		$this->addNumber($view, $config);
59
+		$this->addParam($view);
60
+		$this->addRequest($view);
61
+		$this->addResponse($view);
62
+		$this->addTranslate($view, $locale);
63
+		$this->addUrl($view);
64 64
 
65 65
 		return $view;
66 66
 	}
@@ -73,17 +73,17 @@  discard block
 block discarded – undo
73 73
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context object
74 74
 	 * @return \Aimeos\MW\View\Iface Modified view object
75 75
 	 */
76
-	protected function addAccess( \Aimeos\MW\View\Iface $view, \Aimeos\MShop\Context\Item\Iface $context )
76
+	protected function addAccess(\Aimeos\MW\View\Iface $view, \Aimeos\MShop\Context\Item\Iface $context)
77 77
 	{
78 78
 		$container = $this->container;
79 79
 
80
-		$fcn = function() use ( $container, $context )
80
+		$fcn = function() use ($container, $context)
81 81
 		{
82
-			return $container->get( 'aimeos_support' )->getGroups( $context );
82
+			return $container->get('aimeos_support')->getGroups($context);
83 83
 		};
84 84
 
85
-		$helper = new \Aimeos\MW\View\Helper\Access\Standard( $view, $fcn );
86
-		$view->addHelper( 'access', $helper );
85
+		$helper = new \Aimeos\MW\View\Helper\Access\Standard($view, $fcn);
86
+		$view->addHelper('access', $helper);
87 87
 
88 88
 		return $view;
89 89
 	}
@@ -96,11 +96,11 @@  discard block
 block discarded – undo
96 96
 	 * @param \Aimeos\MW\Config\Iface $config Configuration object
97 97
 	 * @return \Aimeos\MW\View\Iface Modified view object
98 98
 	 */
99
-	protected function addConfig( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config )
99
+	protected function addConfig(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config)
100 100
 	{
101
-		$config = new \Aimeos\MW\Config\Decorator\Protect( clone $config, array( 'admin', 'client' ) );
102
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
103
-		$view->addHelper( 'config', $helper );
101
+		$config = new \Aimeos\MW\Config\Decorator\Protect(clone $config, array('admin', 'client'));
102
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
103
+		$view->addHelper('config', $helper);
104 104
 
105 105
 		return $view;
106 106
 	}
@@ -112,11 +112,11 @@  discard block
 block discarded – undo
112 112
 	 * @param \Aimeos\MW\View\Iface $view View object
113 113
 	 * @return \Aimeos\MW\View\Iface Modified view object
114 114
 	 */
115
-	protected function addCsrf( \Aimeos\MW\View\Iface $view )
115
+	protected function addCsrf(\Aimeos\MW\View\Iface $view)
116 116
 	{
117
-		$token = $this->container->get( 'security.csrf.token_manager' )->getToken( '_token' );
118
-		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_token', $token->getValue() );
119
-		$view->addHelper( 'csrf', $helper );
117
+		$token = $this->container->get('security.csrf.token_manager')->getToken('_token');
118
+		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', $token->getValue());
119
+		$view->addHelper('csrf', $helper);
120 120
 
121 121
 		return $view;
122 122
 	}
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 * @param \Aimeos\MW\Config\Iface $config Configuration object
130 130
 	 * @return \Aimeos\MW\View\Iface Modified view object
131 131
 	 */
132
-	protected function addNumber( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config )
132
+	protected function addNumber(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config)
133 133
 	{
134
-		$sepDec = $config->get( 'client/html/common/format/seperatorDecimal', '.' );
135
-		$sep1000 = $config->get( 'client/html/common/format/seperator1000', ' ' );
136
-		$decimals = $config->get( 'client/html/common/format/decimals', 2 );
134
+		$sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
135
+		$sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
136
+		$decimals = $config->get('client/html/common/format/decimals', 2);
137 137
 
138
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000, $decimals );
139
-		$view->addHelper( 'number', $helper );
138
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000, $decimals);
139
+		$view->addHelper('number', $helper);
140 140
 
141 141
 		return $view;
142 142
 	}
@@ -148,17 +148,17 @@  discard block
 block discarded – undo
148 148
 	 * @param \Aimeos\MW\View\Iface $view View object
149 149
 	 * @return \Aimeos\MW\View\Iface Modified view object
150 150
 	 */
151
-	protected function addParam( \Aimeos\MW\View\Iface $view )
151
+	protected function addParam(\Aimeos\MW\View\Iface $view)
152 152
 	{
153 153
 		$params = array();
154 154
 		$request = $this->requestStack->getMasterRequest();
155 155
 
156
-		if( $request !== null ) {
157
-			$params = $request->request->all() + $request->query->all() + $request->attributes->get( '_route_params' );
156
+		if ($request !== null) {
157
+			$params = $request->request->all() + $request->query->all() + $request->attributes->get('_route_params');
158 158
 		}
159 159
 
160
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params );
161
-		$view->addHelper( 'param', $helper );
160
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
161
+		$view->addHelper('param', $helper);
162 162
 
163 163
 		return $view;
164 164
 	}
@@ -170,14 +170,14 @@  discard block
 block discarded – undo
170 170
 	 * @param \Aimeos\MW\View\Iface $view View object
171 171
 	 * @return \Aimeos\MW\View\Iface Modified view object
172 172
 	 */
173
-	protected function addRequest( \Aimeos\MW\View\Iface $view )
173
+	protected function addRequest(\Aimeos\MW\View\Iface $view)
174 174
 	{
175 175
 		$request = $this->requestStack->getMasterRequest();
176 176
 
177
-		if( $request !== null )
177
+		if ($request !== null)
178 178
 		{
179
-			$helper = new \Aimeos\MW\View\Helper\Request\Symfony2( $view, $request );
180
-			$view->addHelper( 'request', $helper );
179
+			$helper = new \Aimeos\MW\View\Helper\Request\Symfony2($view, $request);
180
+			$view->addHelper('request', $helper);
181 181
 		}
182 182
 
183 183
 		return $view;
@@ -190,10 +190,10 @@  discard block
 block discarded – undo
190 190
 	 * @param \Aimeos\MW\View\Iface $view View object
191 191
 	 * @return \Aimeos\MW\View\Iface Modified view object
192 192
 	 */
193
-	protected function addResponse( \Aimeos\MW\View\Iface $view )
193
+	protected function addResponse(\Aimeos\MW\View\Iface $view)
194 194
 	{
195
-		$helper = new \Aimeos\MW\View\Helper\Response\Symfony2( $view );
196
-		$view->addHelper( 'response', $helper );
195
+		$helper = new \Aimeos\MW\View\Helper\Response\Symfony2($view);
196
+		$view->addHelper('response', $helper);
197 197
 
198 198
 		return $view;
199 199
 	}
@@ -206,20 +206,20 @@  discard block
 block discarded – undo
206 206
 	 * @param string|null $locale ISO language code, e.g. "de" or "de_CH"
207 207
 	 * @return \Aimeos\MW\View\Iface Modified view object
208 208
 	 */
209
-	protected function addTranslate( \Aimeos\MW\View\Iface $view, $locale )
209
+	protected function addTranslate(\Aimeos\MW\View\Iface $view, $locale)
210 210
 	{
211
-		if( $locale !== null )
211
+		if ($locale !== null)
212 212
 		{
213
-			$i18n = $this->container->get( 'aimeos_i18n' )->get( array( $locale ) );
213
+			$i18n = $this->container->get('aimeos_i18n')->get(array($locale));
214 214
 			$translation = $i18n[$locale];
215 215
 		}
216 216
 		else
217 217
 		{
218
-			$translation = new \Aimeos\MW\Translation\None( 'en' );
218
+			$translation = new \Aimeos\MW\Translation\None('en');
219 219
 		}
220 220
 
221
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation );
222
-		$view->addHelper( 'translate', $helper );
221
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
222
+		$view->addHelper('translate', $helper);
223 223
 
224 224
 		return $view;
225 225
 	}
@@ -231,30 +231,30 @@  discard block
 block discarded – undo
231 231
 	 * @param \Aimeos\MW\View\Iface $view View object
232 232
 	 * @return \Aimeos\MW\View\Iface Modified view object
233 233
 	 */
234
-	protected function addUrl( \Aimeos\MW\View\Iface $view )
234
+	protected function addUrl(\Aimeos\MW\View\Iface $view)
235 235
 	{
236 236
 		$fixed = array();
237 237
 		$request = $this->requestStack->getMasterRequest();
238 238
 
239
-		if( $request !== null )
239
+		if ($request !== null)
240 240
 		{
241 241
 			$attr = $request->attributes;
242 242
 
243
-			if( ( $site = $attr->get( 'site' ) ) !== null ) {
243
+			if (($site = $attr->get('site')) !== null) {
244 244
 				$fixed['site'] = $site;
245 245
 			}
246 246
 
247
-			if( ( $lang = $attr->get( 'locale' ) ) !== null ) {
247
+			if (($lang = $attr->get('locale')) !== null) {
248 248
 				$fixed['locale'] = $lang;
249 249
 			}
250 250
 
251
-			if( ( $currency = $attr->get( 'currency' ) ) !== null ) {
251
+			if (($currency = $attr->get('currency')) !== null) {
252 252
 				$fixed['currency'] = $currency;
253 253
 			}
254 254
 		}
255 255
 
256
-		$helper = new \Aimeos\MW\View\Helper\Url\Symfony2( $view, $this->container->get( 'router' ), $fixed );
257
-		$view->addHelper( 'url', $helper );
256
+		$helper = new \Aimeos\MW\View\Helper\Url\Symfony2($view, $this->container->get('router'), $fixed);
257
+		$view->addHelper('url', $helper);
258 258
 
259 259
 		return $view;
260 260
 	}
Please login to merge, or discard this patch.