Completed
Push — master ( a08d75...379a06 )
by Aimeos
02:04
created
src/Controller/Jqadm.php 1 patch
Spacing   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -32,36 +32,36 @@  discard block
 block discarded – undo
32 32
 	 * @param array $args Associative list of route parameters
33 33
 	 * @return ResponseInterface Modified response object with generated output
34 34
 	 */
35
-	public static function fileAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
35
+	public static function fileAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
36 36
 	{
37 37
 		$contents = '';
38 38
 		$files = array();
39
-		$aimeos = $container->get( 'aimeos' );
40
-		$type = ( isset( $args['type'] ) ? $args['type'] : 'js' );
39
+		$aimeos = $container->get('aimeos');
40
+		$type = (isset($args['type']) ? $args['type'] : 'js');
41 41
 
42
-		foreach( $aimeos->getCustomPaths( 'admin/jqadm' ) as $base => $paths )
42
+		foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths)
43 43
 		{
44
-			foreach( $paths as $path )
44
+			foreach ($paths as $path)
45 45
 			{
46
-				$jsbAbsPath = $base . '/' . $path;
47
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) );
48
-				$files = array_merge( $files, $jsb2->getFiles( $type ) );
46
+				$jsbAbsPath = $base.'/'.$path;
47
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath));
48
+				$files = array_merge($files, $jsb2->getFiles($type));
49 49
 			}
50 50
 		}
51 51
 
52
-		foreach( $files as $file )
52
+		foreach ($files as $file)
53 53
 		{
54
-			if( ( $content = file_get_contents( $file ) ) !== false ) {
54
+			if (($content = file_get_contents($file)) !== false) {
55 55
 				$contents .= $content;
56 56
 			}
57 57
 		}
58 58
 
59
-		$response->getBody()->write( $contents );
59
+		$response->getBody()->write($contents);
60 60
 
61
-		if( $type === 'js' ) {
62
-			$response = $response->withHeader( 'Content-Type', 'application/javascript' );
63
-		} elseif( $type === 'css' ) {
64
-			$response = $response->withHeader( 'Content-Type', 'text/css' );
61
+		if ($type === 'js') {
62
+			$response = $response->withHeader('Content-Type', 'application/javascript');
63
+		} elseif ($type === 'css') {
64
+			$response = $response->withHeader('Content-Type', 'text/css');
65 65
 		}
66 66
 
67 67
 		return $response;
@@ -77,15 +77,15 @@  discard block
 block discarded – undo
77 77
 	 * @param array $args Associative list of route parameters
78 78
 	 * @return ResponseInterface Modified response object with generated output
79 79
 	 */
80
-	public static function copyAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
80
+	public static function copyAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
81 81
 	{
82
-		$cntl = self::createClient( $container, $request, $response, $args );
82
+		$cntl = self::createClient($container, $request, $response, $args);
83 83
 
84
-		if( ( $html = $cntl->copy() ) == '' ) {
84
+		if (($html = $cntl->copy()) == '') {
85 85
 			return $cntl->getView()->response();
86 86
 		}
87 87
 
88
-		return self::getHtml( $container, $response, $html );
88
+		return self::getHtml($container, $response, $html);
89 89
 	}
90 90
 
91 91
 
@@ -98,15 +98,15 @@  discard block
 block discarded – undo
98 98
 	 * @param array $args Associative list of route parameters
99 99
 	 * @return ResponseInterface Modified response object with generated output
100 100
 	 */
101
-	public static function createAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
101
+	public static function createAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
102 102
 	{
103
-		$cntl = self::createClient( $container, $request, $response, $args );
103
+		$cntl = self::createClient($container, $request, $response, $args);
104 104
 
105
-		if( ( $html = $cntl->create() ) == '' ) {
105
+		if (($html = $cntl->create()) == '') {
106 106
 			return $cntl->getView()->response();
107 107
 		}
108 108
 
109
-		return self::getHtml( $container, $response, $html );
109
+		return self::getHtml($container, $response, $html);
110 110
 	}
111 111
 
112 112
 
@@ -119,15 +119,15 @@  discard block
 block discarded – undo
119 119
 	 * @param array $args Associative list of route parameters
120 120
 	 * @return ResponseInterface Modified response object with generated output
121 121
 	 */
122
-	public static function deleteAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
122
+	public static function deleteAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
123 123
 	{
124
-		$cntl = self::createClient( $container, $request, $response, $args );
124
+		$cntl = self::createClient($container, $request, $response, $args);
125 125
 
126
-		if( ( $html = $cntl->delete() ) == '' ) {
126
+		if (($html = $cntl->delete()) == '') {
127 127
 			return $cntl->getView()->response();
128 128
 		}
129 129
 
130
-		return self::getHtml( $container, $response, $html );
130
+		return self::getHtml($container, $response, $html);
131 131
 	}
132 132
 
133 133
 
@@ -140,15 +140,15 @@  discard block
 block discarded – undo
140 140
 	 * @param array $args Associative list of route parameters
141 141
 	 * @return ResponseInterface Modified response object with generated output
142 142
 	 */
143
-	public static function exportAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
143
+	public static function exportAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
144 144
 	{
145
-		$cntl = self::createClient( $container, $request, $response, $args );
145
+		$cntl = self::createClient($container, $request, $response, $args);
146 146
 
147
-		if( ( $html = $cntl->export() ) == '' ) {
147
+		if (($html = $cntl->export()) == '') {
148 148
 			return $cntl->getView()->response();
149 149
 		}
150 150
 
151
-		return self::getHtml( $container, $response, $html );
151
+		return self::getHtml($container, $response, $html);
152 152
 	}
153 153
 
154 154
 
@@ -161,15 +161,15 @@  discard block
 block discarded – undo
161 161
 	 * @param array $args Associative list of route parameters
162 162
 	 * @return ResponseInterface Modified response object with generated output
163 163
 	 */
164
-	public static function getAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
164
+	public static function getAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
165 165
 	{
166
-		$cntl = self::createClient( $container, $request, $response, $args );
166
+		$cntl = self::createClient($container, $request, $response, $args);
167 167
 
168
-		if( ( $html = $cntl->get() ) == '' ) {
168
+		if (($html = $cntl->get()) == '') {
169 169
 			return $cntl->getView()->response();
170 170
 		}
171 171
 
172
-		return self::getHtml( $container, $response, $html );
172
+		return self::getHtml($container, $response, $html);
173 173
 	}
174 174
 
175 175
 
@@ -182,15 +182,15 @@  discard block
 block discarded – undo
182 182
 	 * @param array $args Associative list of route parameters
183 183
 	 * @return ResponseInterface Modified response object with generated output
184 184
 	 */
185
-	public static function saveAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
185
+	public static function saveAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
186 186
 	{
187
-		$cntl = self::createClient( $container, $request, $response, $args );
187
+		$cntl = self::createClient($container, $request, $response, $args);
188 188
 
189
-		if( ( $html = $cntl->save() ) == '' ) {
189
+		if (($html = $cntl->save()) == '') {
190 190
 			return $cntl->getView()->response();
191 191
 		}
192 192
 
193
-		return self::getHtml( $container, $response, $html );
193
+		return self::getHtml($container, $response, $html);
194 194
 	}
195 195
 
196 196
 
@@ -203,15 +203,15 @@  discard block
 block discarded – undo
203 203
 	 * @param array $args Associative list of route parameters
204 204
 	 * @return ResponseInterface Modified response object with generated output
205 205
 	 */
206
-	public static function searchAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
206
+	public static function searchAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
207 207
 	{
208
-		$cntl = self::createClient( $container, $request, $response, $args );
208
+		$cntl = self::createClient($container, $request, $response, $args);
209 209
 
210
-		if( ( $html = $cntl->search() ) == '' ) {
210
+		if (($html = $cntl->search()) == '') {
211 211
 			return $cntl->getView()->response();
212 212
 		}
213 213
 
214
-		return self::getHtml( $container, $response, $html );
214
+		return self::getHtml($container, $response, $html);
215 215
 	}
216 216
 
217 217
 
@@ -224,24 +224,24 @@  discard block
 block discarded – undo
224 224
 	 * @param array $args Associative list of route parameters
225 225
 	 * @return \Aimeos\Admin\JQAdm\Iface JQAdm client
226 226
 	 */
227
-	protected static function createClient( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
227
+	protected static function createClient(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
228 228
 	{
229
-		$aimeos = $container->get( 'aimeos' );
230
-		$templatePaths = $aimeos->getCustomPaths( 'admin/jqadm/templates' );
229
+		$aimeos = $container->get('aimeos');
230
+		$templatePaths = $aimeos->getCustomPaths('admin/jqadm/templates');
231 231
 		$params = $args + (array) $request->getParsedBody() + (array) $request->getQueryParams();
232 232
 
233
-		$resource = ( isset( $params['resource'] ) ? $params['resource'] : null );
234
-		$site = ( isset( $params['site'] ) ? $params['site'] : 'default' );
235
-		$lang = ( isset( $params['lang'] ) ? $params['lang'] : 'en' );
233
+		$resource = (isset($params['resource']) ? $params['resource'] : null);
234
+		$site = (isset($params['site']) ? $params['site'] : 'default');
235
+		$lang = (isset($params['lang']) ? $params['lang'] : 'en');
236 236
 
237
-		$context = $container->get( 'aimeos_context' )->get( false, $args, 'backend' );
238
-		$context->setI18n( $container->get( 'aimeos_i18n' )->get( array( $lang, 'en' ) ) );
239
-		$context->setLocale( $container->get( 'aimeos_locale' )->getBackend( $context, $site ) );
237
+		$context = $container->get('aimeos_context')->get(false, $args, 'backend');
238
+		$context->setI18n($container->get('aimeos_i18n')->get(array($lang, 'en')));
239
+		$context->setLocale($container->get('aimeos_locale')->getBackend($context, $site));
240 240
 
241
-		$view = $container->get( 'aimeos_view' )->create( $context, $request, $response, $args, $templatePaths, $lang );
242
-		$context->setView( $view );
241
+		$view = $container->get('aimeos_view')->create($context, $request, $response, $args, $templatePaths, $lang);
242
+		$context->setView($view);
243 243
 
244
-		return \Aimeos\Admin\JQAdm\Factory::createClient( $context, $templatePaths, $resource )->setAimeos( $aimeos );
244
+		return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource)->setAimeos($aimeos);
245 245
 	}
246 246
 
247 247
 
@@ -253,12 +253,12 @@  discard block
 block discarded – undo
253 253
 	 * @param string $content Content from admin client
254 254
 	 * @return ResponseInterface Modified response object with generated output
255 255
 	 */
256
-	protected static function getHtml( ContainerInterface $container, ResponseInterface $response, $content )
256
+	protected static function getHtml(ContainerInterface $container, ResponseInterface $response, $content)
257 257
 	{
258 258
 		$version = \Aimeos\Slim\Bootstrap::getVersion();
259
-		$extnames = implode( ',', $container->get( 'aimeos' )->getExtensions() );
260
-		$content = str_replace( ['{type}', '{version}', '{extensions}'], ['Slim', $version, $extnames], $content );
259
+		$extnames = implode(',', $container->get('aimeos')->getExtensions());
260
+		$content = str_replace(['{type}', '{version}', '{extensions}'], ['Slim', $version, $extnames], $content);
261 261
 
262
-		return $container->get( 'view' )->render( $response, 'Jqadm/index.html.twig', array( 'content' => $content ) );
262
+		return $container->get('view')->render($response, 'Jqadm/index.html.twig', array('content' => $content));
263 263
 	}
264 264
 }
Please login to merge, or discard this patch.