Completed
Push — master ( d17c20...86172d )
by Aimeos
14:29
created
Controller/ExtadmController.php 1 patch
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -30,64 +30,64 @@  discard block
 block discarded – undo
30 30
 	 * @param Request $request Symfony request object
31 31
 	 * @return Response Generated output for the admin interface
32 32
 	 */
33
-	public function indexAction( Request $request )
33
+	public function indexAction(Request $request)
34 34
 	{
35
-		$site = $request->attributes->get( 'site', $request->query->get( 'site', 'default' ) );
36
-		$lang = $request->attributes->get( 'lang', $request->query->get( 'lang', 'en' ) );
37
-		$tab = $request->attributes->get( 'tab', $request->query->get( 'tab', 0 ) );
35
+		$site = $request->attributes->get('site', $request->query->get('site', 'default'));
36
+		$lang = $request->attributes->get('lang', $request->query->get('lang', 'en'));
37
+		$tab = $request->attributes->get('tab', $request->query->get('tab', 0));
38 38
 
39
-		$context = $this->get( 'aimeos_context' )->get( false, 'backend' );
40
-		$context->setLocale( $this->get( 'aimeos_locale' )->getBackend( $context, $site ) );
39
+		$context = $this->get('aimeos_context')->get(false, 'backend');
40
+		$context->setLocale($this->get('aimeos_locale')->getBackend($context, $site));
41 41
 
42
-		$aimeos = $this->get( 'aimeos' );
42
+		$aimeos = $this->get('aimeos');
43 43
 		$bootstrap = $aimeos->get();
44 44
 
45
-		$cntlPaths = $bootstrap->getCustomPaths( 'controller/extjs' );
46
-		$controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths );
45
+		$cntlPaths = $bootstrap->getCustomPaths('controller/extjs');
46
+		$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
47 47
 		$cssFiles = array();
48 48
 
49
-		foreach( $bootstrap->getCustomPaths( 'admin/extjs' ) as $base => $paths )
49
+		foreach ($bootstrap->getCustomPaths('admin/extjs') as $base => $paths)
50 50
 		{
51
-			foreach( $paths as $path )
51
+			foreach ($paths as $path)
52 52
 			{
53
-				$jsbAbsPath = $base . '/' . $path;
53
+				$jsbAbsPath = $base.'/'.$path;
54 54
 
55
-				if( !is_file( $jsbAbsPath ) ) {
56
-					throw new \Exception( sprintf( 'JSB2 file "%1$s" not found', $jsbAbsPath ) );
55
+				if (!is_file($jsbAbsPath)) {
56
+					throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
57 57
 				}
58 58
 
59
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $path ) );
60
-				$cssFiles = array_merge( $cssFiles, $jsb2->getUrls( 'css' ) );
59
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path));
60
+				$cssFiles = array_merge($cssFiles, $jsb2->getUrls('css'));
61 61
 			}
62 62
 		}
63 63
 
64
-		$params = array( 'site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}' );
65
-		$adminUrl = $this->generateUrl( 'aimeos_shop_extadm', $params );
64
+		$params = array('site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}');
65
+		$adminUrl = $this->generateUrl('aimeos_shop_extadm', $params);
66 66
 
67
-		$token = $this->get( 'security.csrf.token_manager' )->getToken( 'aimeos_admin_token' )->getValue();
68
-		$jsonUrl = $this->generateUrl( 'aimeos_shop_extadm_json', array( '_token' => $token, 'site' => $site ) );
67
+		$token = $this->get('security.csrf.token_manager')->getToken('aimeos_admin_token')->getValue();
68
+		$jsonUrl = $this->generateUrl('aimeos_shop_extadm_json', array('_token' => $token, 'site' => $site));
69 69
 
70
-		$jqadmUrl = $this->generateUrl( 'aimeos_shop_jqadm_search', array( 'site' => $site, 'resource' => 'product' ) );
70
+		$jqadmUrl = $this->generateUrl('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product'));
71 71
 
72 72
 		$vars = array(
73 73
 			'lang' => $lang,
74 74
 			'cssFiles' => $cssFiles,
75 75
 			'languages' => $this->getJsonLanguages(),
76
-			'config' => $this->getJsonClientConfig( $context ),
77
-			'site' => $this->getJsonSiteItem( $context, $site ),
78
-			'i18nContent' => $this->getJsonClientI18n( $bootstrap->getI18nPaths(), $lang ),
76
+			'config' => $this->getJsonClientConfig($context),
77
+			'site' => $this->getJsonSiteItem($context, $site),
78
+			'i18nContent' => $this->getJsonClientI18n($bootstrap->getI18nPaths(), $lang),
79 79
 			'searchSchemas' => $controller->getJsonSearchSchemas(),
80 80
 			'itemSchemas' => $controller->getJsonItemSchemas(),
81
-			'smd' => $controller->getJsonSmd( $jsonUrl ),
82
-			'urlTemplate' => urldecode( $adminUrl ),
83
-			'uploaddir' => $this->container->getParameter( 'aimeos_shop.uploaddir' ),
84
-			'extensions' => implode( ',', $bootstrap->getExtensions() ),
81
+			'smd' => $controller->getJsonSmd($jsonUrl),
82
+			'urlTemplate' => urldecode($adminUrl),
83
+			'uploaddir' => $this->container->getParameter('aimeos_shop.uploaddir'),
84
+			'extensions' => implode(',', $bootstrap->getExtensions()),
85 85
 			'version' => $aimeos->getVersion(),
86 86
 			'jqadmurl' => $jqadmUrl,
87 87
 			'activeTab' => $tab,
88 88
 		);
89 89
 
90
-		return $this->render( 'AimeosShopBundle:Extadm:index.html.twig', $vars );
90
+		return $this->render('AimeosShopBundle:Extadm:index.html.twig', $vars);
91 91
 	}
92 92
 
93 93
 
@@ -97,23 +97,23 @@  discard block
 block discarded – undo
97 97
 	 * @param Request $request Symfony request object
98 98
 	 * @return Response JSON RPC message response
99 99
 	 */
100
-	public function doAction( Request $request )
100
+	public function doAction(Request $request)
101 101
 	{
102 102
 		$csrfProvider = $this->get('security.csrf.token_manager');
103 103
 
104
-		if( $csrfProvider->isTokenValid( new CsrfToken( 'aimeos_admin_token',  $request->query->get( '_token' ) ) ) !== true ) {
105
-			throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException( 'CSRF token is invalid' );
104
+		if ($csrfProvider->isTokenValid(new CsrfToken('aimeos_admin_token', $request->query->get('_token'))) !== true) {
105
+			throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException('CSRF token is invalid');
106 106
 		}
107 107
 
108
-		$cntlPaths = $this->get( 'aimeos' )->get()->getCustomPaths( 'controller/extjs' );
109
-		$context = $this->get( 'aimeos_context' )->get( false, 'backend' );
110
-		$context->setView( $this->get( 'aimeos_view' )->create( $context, array() ) );
111
-		$context->setLocale( $this->get( 'aimeos_locale' )->getBackend( $context, 'default' ) );
108
+		$cntlPaths = $this->get('aimeos')->get()->getCustomPaths('controller/extjs');
109
+		$context = $this->get('aimeos_context')->get(false, 'backend');
110
+		$context->setView($this->get('aimeos_view')->create($context, array()));
111
+		$context->setLocale($this->get('aimeos_locale')->getBackend($context, 'default'));
112 112
 
113
-		$controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths );
113
+		$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
114 114
 
115
-		$response = $controller->process( $request->request->all(), $request->getContent() );
116
-		return $this->render( 'AimeosShopBundle:Extadm:do.html.twig', array( 'output' => $response ) );
115
+		$response = $controller->process($request->request->all(), $request->getContent());
116
+		return $this->render('AimeosShopBundle:Extadm:do.html.twig', array('output' => $response));
117 117
 	}
118 118
 
119 119
 
@@ -126,27 +126,27 @@  discard block
 block discarded – undo
126 126
 	{
127 127
 		$contents = '';
128 128
 		$jsFiles = array();
129
-		$aimeos = $this->get( 'aimeos' )->get();
129
+		$aimeos = $this->get('aimeos')->get();
130 130
 
131
-		foreach( $aimeos->getCustomPaths( 'admin/extjs' ) as $base => $paths )
131
+		foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths)
132 132
 		{
133
-			foreach( $paths as $path )
133
+			foreach ($paths as $path)
134 134
 			{
135
-				$jsbAbsPath = $base . '/' . $path;
136
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) );
137
-				$jsFiles = array_merge( $jsFiles, $jsb2->getFiles( 'js' ) );
135
+				$jsbAbsPath = $base.'/'.$path;
136
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath));
137
+				$jsFiles = array_merge($jsFiles, $jsb2->getFiles('js'));
138 138
 			}
139 139
 		}
140 140
 
141
-		foreach( $jsFiles as $file )
141
+		foreach ($jsFiles as $file)
142 142
 		{
143
-			if( ( $content = file_get_contents( $file ) ) !== false ) {
143
+			if (($content = file_get_contents($file)) !== false) {
144 144
 				$contents .= $content;
145 145
 			}
146 146
 		}
147 147
 
148
-		$response = new Response( $contents );
149
-		$response->headers->set( 'Content-Type', 'application/javascript' );
148
+		$response = new Response($contents);
149
+		$response->headers->set('Content-Type', 'application/javascript');
150 150
 
151 151
 		return $response;
152 152
 	}
@@ -161,11 +161,11 @@  discard block
 block discarded – undo
161 161
 	{
162 162
 		$result = array();
163 163
 
164
-		foreach( $this->get( 'aimeos' )->get()->getI18nList( 'admin' ) as $id ) {
165
-			$result[] = array( 'id' => $id, 'label' => $id );
164
+		foreach ($this->get('aimeos')->get()->getI18nList('admin') as $id) {
165
+			$result[] = array('id' => $id, 'label' => $id);
166 166
 		}
167 167
 
168
-		return json_encode( $result );
168
+		return json_encode($result);
169 169
 	}
170 170
 
171 171
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
176 176
 	 * @return string JSON encoded configuration object
177 177
 	 */
178
-	protected function getJsonClientConfig( \Aimeos\MShop\Context\Item\Iface $context )
178
+	protected function getJsonClientConfig(\Aimeos\MShop\Context\Item\Iface $context)
179 179
 	{
180
-		$config = $context->getConfig()->get( 'admin/extjs', array() );
181
-		return json_encode( array( 'admin' => array( 'extjs' => $config ) ), JSON_FORCE_OBJECT );
180
+		$config = $context->getConfig()->get('admin/extjs', array());
181
+		return json_encode(array('admin' => array('extjs' => $config)), JSON_FORCE_OBJECT);
182 182
 	}
183 183
 
184 184
 
@@ -189,16 +189,16 @@  discard block
 block discarded – undo
189 189
 	 * @param string $lang ISO language code like "en" or "en_GB"
190 190
 	 * @return string JSON encoded translation object
191 191
 	 */
192
-	protected function getJsonClientI18n( array $i18nPaths, $lang )
192
+	protected function getJsonClientI18n(array $i18nPaths, $lang)
193 193
 	{
194
-		$i18n = new \Aimeos\MW\Translation\Gettext( $i18nPaths, $lang );
194
+		$i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $lang);
195 195
 
196 196
 		$content = array(
197
-			'admin' => $i18n->getAll( 'admin' ),
198
-			'admin/ext' => $i18n->getAll( 'admin/ext' ),
197
+			'admin' => $i18n->getAll('admin'),
198
+			'admin/ext' => $i18n->getAll('admin/ext'),
199 199
 		);
200 200
 
201
-		return json_encode( $content, JSON_FORCE_OBJECT );
201
+		return json_encode($content, JSON_FORCE_OBJECT);
202 202
 	}
203 203
 
204 204
 
@@ -210,18 +210,18 @@  discard block
 block discarded – undo
210 210
 	 * @return string JSON encoded site item object
211 211
 	 * @throws Exception If no site item was found for the code
212 212
 	 */
213
-	protected function getJsonSiteItem( \Aimeos\MShop\Context\Item\Iface $context, $site )
213
+	protected function getJsonSiteItem(\Aimeos\MShop\Context\Item\Iface $context, $site)
214 214
 	{
215
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'locale/site' );
215
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'locale/site');
216 216
 
217 217
 		$criteria = $manager->createSearch();
218
-		$criteria->setConditions( $criteria->compare( '==', 'locale.site.code', $site ) );
219
-		$items = $manager->searchItems( $criteria );
218
+		$criteria->setConditions($criteria->compare('==', 'locale.site.code', $site));
219
+		$items = $manager->searchItems($criteria);
220 220
 
221
-		if( ( $item = reset( $items ) ) === false ) {
222
-			throw new \Exception( sprintf( 'No site found for code "%1$s"', $site ) );
221
+		if (($item = reset($items)) === false) {
222
+			throw new \Exception(sprintf('No site found for code "%1$s"', $site));
223 223
 		}
224 224
 
225
-		return json_encode( $item->toArray() );
225
+		return json_encode($item->toArray());
226 226
 	}
227 227
 }
Please login to merge, or discard this patch.
Controller/JqadmController.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -29,35 +29,35 @@  discard block
 block discarded – undo
29 29
 	 * @param $type File type, i.e. "css" or "js"
30 30
 	 * @return Response Response object
31 31
 	 */
32
-	public function fileAction( $type )
32
+	public function fileAction($type)
33 33
 	{
34 34
 		$contents = '';
35 35
 		$files = array();
36
-		$aimeos = $this->get( 'aimeos' )->get();
36
+		$aimeos = $this->get('aimeos')->get();
37 37
 
38
-		foreach( $aimeos->getCustomPaths( 'admin/jqadm' ) as $base => $paths )
38
+		foreach ($aimeos->getCustomPaths('admin/jqadm') as $base => $paths)
39 39
 		{
40
-			foreach( $paths as $path )
40
+			foreach ($paths as $path)
41 41
 			{
42
-				$jsbAbsPath = $base . '/' . $path;
43
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) );
44
-				$files = array_merge( $files, $jsb2->getFiles( $type ) );
42
+				$jsbAbsPath = $base.'/'.$path;
43
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath));
44
+				$files = array_merge($files, $jsb2->getFiles($type));
45 45
 			}
46 46
 		}
47 47
 
48
-		foreach( $files as $file )
48
+		foreach ($files as $file)
49 49
 		{
50
-			if( ( $content = file_get_contents( $file ) ) !== false ) {
50
+			if (($content = file_get_contents($file)) !== false) {
51 51
 				$contents .= $content;
52 52
 			}
53 53
 		}
54 54
 
55
-		$response = new Response( $contents );
55
+		$response = new Response($contents);
56 56
 
57
-		if( $type === 'js' ) {
58
-			$response->headers->set( 'Content-Type', 'application/javascript' );
59
-		} elseif( $type === 'css' ) {
60
-			$response->headers->set( 'Content-Type', 'text/css' );
57
+		if ($type === 'js') {
58
+			$response->headers->set('Content-Type', 'application/javascript');
59
+		} elseif ($type === 'css') {
60
+			$response->headers->set('Content-Type', 'text/css');
61 61
 		}
62 62
 
63 63
 		return $response;
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 	 * @param string $site Unique site code
73 73
 	 * @return Response Generated output
74 74
 	 */
75
-	public function copyAction( Request $request, $resource, $site = 'default' )
75
+	public function copyAction(Request $request, $resource, $site = 'default')
76 76
 	{
77
-		$cntl = $this->createClient( $request, $site, $resource );
78
-		return $this->getHtml( $cntl->copy() );
77
+		$cntl = $this->createClient($request, $site, $resource);
78
+		return $this->getHtml($cntl->copy());
79 79
 	}
80 80
 
81 81
 
@@ -87,10 +87,10 @@  discard block
 block discarded – undo
87 87
 	 * @param string $site Unique site code
88 88
 	 * @return Response Generated output
89 89
 	 */
90
-	public function createAction( Request $request, $resource, $site = 'default' )
90
+	public function createAction(Request $request, $resource, $site = 'default')
91 91
 	{
92
-		$cntl = $this->createClient( $request, $site, $resource );
93
-		return $this->getHtml( $cntl->create() );
92
+		$cntl = $this->createClient($request, $site, $resource);
93
+		return $this->getHtml($cntl->create());
94 94
 	}
95 95
 
96 96
 
@@ -102,10 +102,10 @@  discard block
 block discarded – undo
102 102
 	 * @param string $site Unique site code
103 103
 	 * @return Response Generated output
104 104
 	 */
105
-	public function deleteAction( Request $request, $resource, $site = 'default' )
105
+	public function deleteAction(Request $request, $resource, $site = 'default')
106 106
 	{
107
-		$cntl = $this->createClient( $request, $site, $resource );
108
-		return $this->getHtml( $cntl->delete() . $cntl->search() );
107
+		$cntl = $this->createClient($request, $site, $resource);
108
+		return $this->getHtml($cntl->delete().$cntl->search());
109 109
 	}
110 110
 
111 111
 
@@ -117,10 +117,10 @@  discard block
 block discarded – undo
117 117
 	 * @param string $site Unique site code
118 118
 	 * @return Response Generated output
119 119
 	 */
120
-	public function getAction( Request $request, $resource, $site = 'default' )
120
+	public function getAction(Request $request, $resource, $site = 'default')
121 121
 	{
122
-		$cntl = $this->createClient( $request, $site, $resource );
123
-		return $this->getHtml( $cntl->get() );
122
+		$cntl = $this->createClient($request, $site, $resource);
123
+		return $this->getHtml($cntl->get());
124 124
 	}
125 125
 
126 126
 
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
 	 * @param string $site Unique site code
133 133
 	 * @return Response Generated output
134 134
 	 */
135
-	public function saveAction( Request $request, $resource, $site = 'default' )
135
+	public function saveAction(Request $request, $resource, $site = 'default')
136 136
 	{
137
-		$cntl = $this->createClient( $request, $site, $resource );
138
-		return $this->getHtml( ( $cntl->save() ? : $cntl->search() ) );
137
+		$cntl = $this->createClient($request, $site, $resource);
138
+		return $this->getHtml(($cntl->save() ?: $cntl->search()));
139 139
 	}
140 140
 
141 141
 
@@ -147,10 +147,10 @@  discard block
 block discarded – undo
147 147
 	 * @param string $site Unique site code
148 148
 	 * @return Response Generated output
149 149
 	 */
150
-	public function searchAction( Request $request, $resource, $site = 'default' )
150
+	public function searchAction(Request $request, $resource, $site = 'default')
151 151
 	{
152
-		$cntl = $this->createClient( $request, $site, $resource );
153
-		return $this->getHtml( $cntl->search() );
152
+		$cntl = $this->createClient($request, $site, $resource);
153
+		return $this->getHtml($cntl->search());
154 154
 	}
155 155
 
156 156
 
@@ -162,21 +162,21 @@  discard block
 block discarded – undo
162 162
 	 * @param string $resource Resource location, e.g. "product"
163 163
 	 * @return \Aimeos\Admin\JQAdm\Iface Context item
164 164
 	 */
165
-	protected function createClient( Request $request, $site, $resource )
165
+	protected function createClient(Request $request, $site, $resource)
166 166
 	{
167
-		$lang = $request->get( 'lang', 'en' );
167
+		$lang = $request->get('lang', 'en');
168 168
 
169
-		$aimeos = $this->get( 'aimeos' )->get();
170
-		$templatePaths = $aimeos->getCustomPaths( 'admin/jqadm/templates' );
169
+		$aimeos = $this->get('aimeos')->get();
170
+		$templatePaths = $aimeos->getCustomPaths('admin/jqadm/templates');
171 171
 
172
-		$context = $this->get( 'aimeos_context' )->get( false, 'backend' );
173
-		$context->setI18n( $this->get( 'aimeos_i18n' )->get( array( $lang, 'en' ) ) );
174
-		$context->setLocale( $this->get( 'aimeos_locale' )->getBackend( $context, $site ) );
172
+		$context = $this->get('aimeos_context')->get(false, 'backend');
173
+		$context->setI18n($this->get('aimeos_i18n')->get(array($lang, 'en')));
174
+		$context->setLocale($this->get('aimeos_locale')->getBackend($context, $site));
175 175
 
176
-		$view = $this->get( 'aimeos_view' )->create( $context, $templatePaths, $lang );
177
-		$context->setView( $view );
176
+		$view = $this->get('aimeos_view')->create($context, $templatePaths, $lang);
177
+		$context->setView($view);
178 178
 
179
-		return \Aimeos\Admin\JQAdm\Factory::createClient( $context, $templatePaths, $resource );
179
+		return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource);
180 180
 	}
181 181
 
182 182
 
@@ -186,12 +186,12 @@  discard block
 block discarded – undo
186 186
 	 * @param string $content Content from admin client
187 187
 	 * @return Response View for rendering the output
188 188
 	 */
189
-	protected function getHtml( $content )
189
+	protected function getHtml($content)
190 190
 	{
191
-		$version = $this->get( 'aimeos' )->getVersion();
192
-		$extnames = implode( ',', $this->get( 'aimeos' )->get()->getExtensions() );
193
-		$content = str_replace( ['{type}', '{version}', '{extensions}'], ['Symfony', $version, $extnames], $content );
191
+		$version = $this->get('aimeos')->getVersion();
192
+		$extnames = implode(',', $this->get('aimeos')->get()->getExtensions());
193
+		$content = str_replace(['{type}', '{version}', '{extensions}'], ['Symfony', $version, $extnames], $content);
194 194
 
195
-		return $this->render( 'AimeosShopBundle:Jqadm:index.html.twig', array( 'content' => $content ) );
195
+		return $this->render('AimeosShopBundle:Jqadm:index.html.twig', array('content' => $content));
196 196
 	}
197 197
 }
Please login to merge, or discard this patch.