Completed
Push — master ( 4f1a9d...4141a4 )
by Aimeos
02:14
created
src/Base/View.php 1 patch
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 	 *
31 31
 	 * @param ContainerInterface $container Dependency container
32 32
 	 */
33
-	public function __construct( ContainerInterface $container )
33
+	public function __construct(ContainerInterface $container)
34 34
 	{
35 35
 		$this->container = $container;
36 36
 	}
@@ -47,22 +47,22 @@  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\MW\Config\Iface $config, ServerRequestInterface $request,
51
-		ResponseInterface $response, array $attributes, array $templatePaths, $locale = null )
50
+	public function create(\Aimeos\MW\Config\Iface $config, ServerRequestInterface $request,
51
+		ResponseInterface $response, array $attributes, array $templatePaths, $locale = null)
52 52
 	{
53 53
 		$params = $attributes + (array) $request->getParsedBody() + (array) $request->getQueryParams();
54 54
 
55
-		$view = new \Aimeos\MW\View\Standard( $templatePaths );
55
+		$view = new \Aimeos\MW\View\Standard($templatePaths);
56 56
 
57
-		$this->addAccess( $view );
58
-		$this->addConfig( $view, $config );
59
-		$this->addCsrf( $view, $request );
60
-		$this->addNumber( $view, $config );
61
-		$this->addParam( $view, $params );
62
-		$this->addRequest( $view, $request );
63
-		$this->addResponse( $view, $response );
64
-		$this->addTranslate( $view, $locale );
65
-		$this->addUrl( $view, $attributes );
57
+		$this->addAccess($view);
58
+		$this->addConfig($view, $config);
59
+		$this->addCsrf($view, $request);
60
+		$this->addNumber($view, $config);
61
+		$this->addParam($view, $params);
62
+		$this->addRequest($view, $request);
63
+		$this->addResponse($view, $response);
64
+		$this->addTranslate($view, $locale);
65
+		$this->addUrl($view, $attributes);
66 66
 
67 67
 		return $view;
68 68
 	}
@@ -74,10 +74,10 @@  discard block
 block discarded – undo
74 74
 	 * @param \Aimeos\MW\View\Iface $view View object
75 75
 	 * @return \Aimeos\MW\View\Iface Modified view object
76 76
 	 */
77
-	protected function addAccess( \Aimeos\MW\View\Iface $view )
77
+	protected function addAccess(\Aimeos\MW\View\Iface $view)
78 78
 	{
79
-		$helper = new \Aimeos\MW\View\Helper\Access\All( $view );
80
-		$view->addHelper( 'access', $helper );
79
+		$helper = new \Aimeos\MW\View\Helper\Access\All($view);
80
+		$view->addHelper('access', $helper);
81 81
 
82 82
 		return $view;
83 83
 	}
@@ -90,11 +90,11 @@  discard block
 block discarded – undo
90 90
 	 * @param \Aimeos\MW\Config\Iface $config Configuration object
91 91
 	 * @return \Aimeos\MW\View\Iface Modified view object
92 92
 	 */
93
-	protected function addConfig( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config )
93
+	protected function addConfig(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config)
94 94
 	{
95
-		$config = new \Aimeos\MW\Config\Decorator\Protect( clone $config, array( 'admin', 'client' ) );
96
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
97
-		$view->addHelper( 'config', $helper );
95
+		$config = new \Aimeos\MW\Config\Decorator\Protect(clone $config, array('admin', 'client'));
96
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
97
+		$view->addHelper('config', $helper);
98 98
 
99 99
 		return $view;
100 100
 	}
@@ -107,13 +107,13 @@  discard block
 block discarded – undo
107 107
 	 * @param ServerRequestInterface $request Request object
108 108
 	 * @return \Aimeos\MW\View\Iface Modified view object
109 109
 	 */
110
-	protected function addCsrf( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request )
110
+	protected function addCsrf(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request)
111 111
 	{
112
-		$name = $request->getAttribute( 'csrf_name' );
113
-		$value = $request->getAttribute( 'csrf_value' );
112
+		$name = $request->getAttribute('csrf_name');
113
+		$value = $request->getAttribute('csrf_value');
114 114
 
115
-		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, $name, $value );
116
-		$view->addHelper( 'csrf', $helper );
115
+		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, $name, $value);
116
+		$view->addHelper('csrf', $helper);
117 117
 
118 118
 		return $view;
119 119
 	}
@@ -126,14 +126,14 @@  discard block
 block discarded – undo
126 126
 	 * @param \Aimeos\MW\Config\Iface $config Configuration object
127 127
 	 * @return \Aimeos\MW\View\Iface Modified view object
128 128
 	 */
129
-	protected function addNumber( \Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config )
129
+	protected function addNumber(\Aimeos\MW\View\Iface $view, \Aimeos\MW\Config\Iface $config)
130 130
 	{
131
-		$sepDec = $config->get( 'client/html/common/format/seperatorDecimal', '.' );
132
-		$sep1000 = $config->get( 'client/html/common/format/seperator1000', ' ' );
133
-		$decimals = $config->get( 'client/html/common/format/decimals', 2 );
131
+		$sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
132
+		$sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
133
+		$decimals = $config->get('client/html/common/format/decimals', 2);
134 134
 
135
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000, $decimals );
136
-		$view->addHelper( 'number', $helper );
135
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000, $decimals);
136
+		$view->addHelper('number', $helper);
137 137
 
138 138
 		return $view;
139 139
 	}
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
 	 * @param array $attributes Associative list of request parameters
147 147
 	 * @return \Aimeos\MW\View\Iface Modified view object
148 148
 	 */
149
-	protected static function addParam( \Aimeos\MW\View\Iface $view, array $params )
149
+	protected static function addParam(\Aimeos\MW\View\Iface $view, array $params)
150 150
 	{
151
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params );
152
-		$view->addHelper( 'param', $helper );
151
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
152
+		$view->addHelper('param', $helper);
153 153
 
154 154
 		return $view;
155 155
 	}
@@ -162,10 +162,10 @@  discard block
 block discarded – undo
162 162
 	 * @param ServerRequestInterface $request Request object
163 163
 	 * @return \Aimeos\MW\View\Iface Modified view object
164 164
 	 */
165
-	protected static function addRequest( \Aimeos\MW\View\Iface $view, ServerRequestInterface $request )
165
+	protected static function addRequest(\Aimeos\MW\View\Iface $view, ServerRequestInterface $request)
166 166
 	{
167
-		$helper = new \Aimeos\MW\View\Helper\Request\Slim( $view, $request );
168
-		$view->addHelper( 'request', $helper );
167
+		$helper = new \Aimeos\MW\View\Helper\Request\Slim($view, $request);
168
+		$view->addHelper('request', $helper);
169 169
 
170 170
 		return $view;
171 171
 	}
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 * @param ResponseInterface $response Response object
179 179
 	 * @return \Aimeos\MW\View\Iface Modified view object
180 180
 	 */
181
-	protected static function addResponse( \Aimeos\MW\View\Iface $view, ResponseInterface $response )
181
+	protected static function addResponse(\Aimeos\MW\View\Iface $view, ResponseInterface $response)
182 182
 	{
183
-		$helper = new \Aimeos\MW\View\Helper\Response\Slim( $view, $response );
184
-		$view->addHelper( 'response', $helper );
183
+		$helper = new \Aimeos\MW\View\Helper\Response\Slim($view, $response);
184
+		$view->addHelper('response', $helper);
185 185
 
186 186
 		return $view;
187 187
 	}
@@ -194,20 +194,20 @@  discard block
 block discarded – undo
194 194
 	 * @param string|null $locale ISO language code, e.g. "de" or "de_CH"
195 195
 	 * @return \Aimeos\MW\View\Iface Modified view object
196 196
 	 */
197
-	protected function addTranslate( \Aimeos\MW\View\Iface $view, $locale )
197
+	protected function addTranslate(\Aimeos\MW\View\Iface $view, $locale)
198 198
 	{
199
-		if( $locale !== null )
199
+		if ($locale !== null)
200 200
 		{
201
-			$i18n = $this->container->get( 'aimeos_i18n' )->get( array( $locale ) );
201
+			$i18n = $this->container->get('aimeos_i18n')->get(array($locale));
202 202
 			$translation = $i18n[$locale];
203 203
 		}
204 204
 		else
205 205
 		{
206
-			$translation = new \Aimeos\MW\Translation\None( 'en' );
206
+			$translation = new \Aimeos\MW\Translation\None('en');
207 207
 		}
208 208
 
209
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation );
210
-		$view->addHelper( 'translate', $helper );
209
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
210
+		$view->addHelper('translate', $helper);
211 211
 
212 212
 		return $view;
213 213
 	}
@@ -220,24 +220,24 @@  discard block
 block discarded – undo
220 220
 	 * @param array $attributes Associative list of URI parameters
221 221
 	 * @return \Aimeos\MW\View\Iface Modified view object
222 222
 	 */
223
-	protected function addUrl( \Aimeos\MW\View\Iface $view, array $attributes )
223
+	protected function addUrl(\Aimeos\MW\View\Iface $view, array $attributes)
224 224
 	{
225 225
 		$fixed = array();
226 226
 
227
-		if( isset( $attributes['site'] ) ) {
227
+		if (isset($attributes['site'])) {
228 228
 			$fixed['site'] = $attributes['site'];
229 229
 		}
230 230
 
231
-		if( isset( $attributes['locale'] ) ) {
231
+		if (isset($attributes['locale'])) {
232 232
 			$fixed['locale'] = $attributes['locale'];
233 233
 		}
234 234
 
235
-		if( isset( $attributes['currency'] ) ) {
235
+		if (isset($attributes['currency'])) {
236 236
 			$fixed['currency'] = $attributes['currency'];
237 237
 		}
238 238
 
239
-		$helper = new \Aimeos\MW\View\Helper\Url\Slim( $view, $this->container->get( 'router' ), $fixed );
240
-		$view->addHelper( 'url', $helper );
239
+		$helper = new \Aimeos\MW\View\Helper\Url\Slim($view, $this->container->get('router'), $fixed);
240
+		$view->addHelper('url', $helper);
241 241
 
242 242
 		return $view;
243 243
 	}
Please login to merge, or discard this patch.