Completed
Push — master ( 57e5a6...06d3b4 )
by Aimeos
02:53
created
Controller/ExtadmController.php 1 patch
Spacing   +68 added lines, -68 removed lines patch added patch discarded remove patch
@@ -30,62 +30,62 @@  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', 'default' );
36
-		$lang = $request->query->get( 'lang', 'en' );
35
+		$site = $request->attributes->get('site', 'default');
36
+		$lang = $request->query->get('lang', 'en');
37 37
 
38
-		$context = $this->get( 'aimeos_context' )->get( false );
39
-		$context = $this->setLocale( $context, $site, $lang );
38
+		$context = $this->get('aimeos_context')->get(false);
39
+		$context = $this->setLocale($context, $site, $lang);
40 40
 
41
-		$aimeos = $this->get( 'aimeos' );
41
+		$aimeos = $this->get('aimeos');
42 42
 		$bootstrap = $aimeos->get();
43 43
 
44
-		$cntlPaths = $bootstrap->getCustomPaths( 'controller/extjs' );
45
-		$controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths );
44
+		$cntlPaths = $bootstrap->getCustomPaths('controller/extjs');
45
+		$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
46 46
 		$cssFiles = array();
47 47
 
48
-		foreach( $bootstrap->getCustomPaths( 'admin/extjs' ) as $base => $paths )
48
+		foreach ($bootstrap->getCustomPaths('admin/extjs') as $base => $paths)
49 49
 		{
50
-			foreach( $paths as $path )
50
+			foreach ($paths as $path)
51 51
 			{
52 52
 				$jsbAbsPath = $base . '/' . $path;
53 53
 
54
-				if( !is_file( $jsbAbsPath ) ) {
55
-					throw new \Exception( sprintf( 'JSB2 file "%1$s" not found', $jsbAbsPath ) );
54
+				if (!is_file($jsbAbsPath)) {
55
+					throw new \Exception(sprintf('JSB2 file "%1$s" not found', $jsbAbsPath));
56 56
 				}
57 57
 
58
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $path ) );
59
-				$cssFiles = array_merge( $cssFiles, $jsb2->getUrls( 'css' ) );
58
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($path));
59
+				$cssFiles = array_merge($cssFiles, $jsb2->getUrls('css'));
60 60
 			}
61 61
 		}
62 62
 
63
-		$params = array( 'site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}' );
64
-		$adminUrl = $this->generateUrl( 'aimeos_shop_extadm', $params );
63
+		$params = array('site' => '{site}', 'lang' => '{lang}', 'tab' => '{tab}');
64
+		$adminUrl = $this->generateUrl('aimeos_shop_extadm', $params);
65 65
 
66
-		$token = $this->get( 'security.csrf.token_manager' )->getToken( 'aimeos_admin_token' )->getValue();
67
-		$jsonUrl = $this->generateUrl( 'aimeos_shop_extadm_json', array( '_token' => $token, 'site' => $site ) );
66
+		$token = $this->get('security.csrf.token_manager')->getToken('aimeos_admin_token')->getValue();
67
+		$jsonUrl = $this->generateUrl('aimeos_shop_extadm_json', array('_token' => $token, 'site' => $site));
68 68
 
69
-		$jqadmUrl = $this->generateUrl( 'aimeos_shop_jqadm_search', array( 'site' => $site, 'resource' => 'product' ) );
69
+		$jqadmUrl = $this->generateUrl('aimeos_shop_jqadm_search', array('site' => $site, 'resource' => 'product'));
70 70
 
71 71
 		$vars = array(
72 72
 			'lang' => $lang,
73 73
 			'cssFiles' => $cssFiles,
74 74
 			'languages' => $this->getJsonLanguages(),
75
-			'config' => $this->getJsonClientConfig( $context ),
76
-			'site' => $this->getJsonSiteItem( $context, $site ),
77
-			'i18nContent' => $this->getJsonClientI18n( $bootstrap->getI18nPaths(), $lang ),
75
+			'config' => $this->getJsonClientConfig($context),
76
+			'site' => $this->getJsonSiteItem($context, $site),
77
+			'i18nContent' => $this->getJsonClientI18n($bootstrap->getI18nPaths(), $lang),
78 78
 			'searchSchemas' => $controller->getJsonSearchSchemas(),
79 79
 			'itemSchemas' => $controller->getJsonItemSchemas(),
80
-			'smd' => $controller->getJsonSmd( $jsonUrl ),
81
-			'urlTemplate' => urldecode( $adminUrl ),
82
-			'uploaddir' => $this->container->getParameter( 'aimeos_shop.uploaddir' ),
83
-			'activeTab' => $request->query->get( 'tab', 0 ),
80
+			'smd' => $controller->getJsonSmd($jsonUrl),
81
+			'urlTemplate' => urldecode($adminUrl),
82
+			'uploaddir' => $this->container->getParameter('aimeos_shop.uploaddir'),
83
+			'activeTab' => $request->query->get('tab', 0),
84 84
 			'version' => $aimeos->getVersion(),
85 85
 			'jqadmurl' => $jqadmUrl,
86 86
 		);
87 87
 
88
-		return $this->render( 'AimeosShopBundle:Extadm:index.html.twig', $vars );
88
+		return $this->render('AimeosShopBundle:Extadm:index.html.twig', $vars);
89 89
 	}
90 90
 
91 91
 
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
 	 * @param Request $request Symfony request object
96 96
 	 * @return Response JSON RPC message response
97 97
 	 */
98
-	public function doAction( Request $request )
98
+	public function doAction(Request $request)
99 99
 	{
100 100
 		$csrfProvider = $this->get('security.csrf.token_manager');
101 101
 
102
-		if( $csrfProvider->isTokenValid( new CsrfToken( 'aimeos_admin_token',  $request->query->get( '_token' ) ) ) !== true ) {
103
-			throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException( 'CSRF token is invalid' );
102
+		if ($csrfProvider->isTokenValid(new CsrfToken('aimeos_admin_token', $request->query->get('_token'))) !== true) {
103
+			throw new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException('CSRF token is invalid');
104 104
 		}
105 105
 
106
-		$cntlPaths = $this->get( 'aimeos' )->get()->getCustomPaths( 'controller/extjs' );
107
-		$context = $this->get( 'aimeos_context' )->get( false );
108
-		$context = $this->setLocale( $context );
106
+		$cntlPaths = $this->get('aimeos')->get()->getCustomPaths('controller/extjs');
107
+		$context = $this->get('aimeos_context')->get(false);
108
+		$context = $this->setLocale($context);
109 109
 
110
-		$controller = new \Aimeos\Controller\ExtJS\JsonRpc( $context, $cntlPaths );
110
+		$controller = new \Aimeos\Controller\ExtJS\JsonRpc($context, $cntlPaths);
111 111
 
112
-		$response = $controller->process( $request->request->all(), 'php://input' );
113
-		return $this->render( 'AimeosShopBundle:Extadm:do.html.twig', array( 'output' => $response ) );
112
+		$response = $controller->process($request->request->all(), 'php://input');
113
+		return $this->render('AimeosShopBundle:Extadm:do.html.twig', array('output' => $response));
114 114
 	}
115 115
 
116 116
 
@@ -123,27 +123,27 @@  discard block
 block discarded – undo
123 123
 	{
124 124
 		$contents = '';
125 125
 		$jsFiles = array();
126
-		$aimeos = $this->get( 'aimeos' )->get();
126
+		$aimeos = $this->get('aimeos')->get();
127 127
 
128
-		foreach( $aimeos->getCustomPaths( 'admin/extjs' ) as $base => $paths )
128
+		foreach ($aimeos->getCustomPaths('admin/extjs') as $base => $paths)
129 129
 		{
130
-			foreach( $paths as $path )
130
+			foreach ($paths as $path)
131 131
 			{
132 132
 				$jsbAbsPath = $base . '/' . $path;
133
-				$jsb2 = new \Aimeos\MW\Jsb2\Standard( $jsbAbsPath, dirname( $jsbAbsPath ) );
134
-				$jsFiles = array_merge( $jsFiles, $jsb2->getFiles( 'js' ) );
133
+				$jsb2 = new \Aimeos\MW\Jsb2\Standard($jsbAbsPath, dirname($jsbAbsPath));
134
+				$jsFiles = array_merge($jsFiles, $jsb2->getFiles('js'));
135 135
 			}
136 136
 		}
137 137
 
138
-		foreach( $jsFiles as $file )
138
+		foreach ($jsFiles as $file)
139 139
 		{
140
-			if( ( $content = file_get_contents( $file ) ) !== false ) {
140
+			if (($content = file_get_contents($file)) !== false) {
141 141
 				$contents .= $content;
142 142
 			}
143 143
 		}
144 144
 
145
-		$response = new Response( $contents );
146
-		$response->headers->set( 'Content-Type', 'application/javascript' );
145
+		$response = new Response($contents);
146
+		$response->headers->set('Content-Type', 'application/javascript');
147 147
 
148 148
 		return $response;
149 149
 	}
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 	{
159 159
 		$result = array();
160 160
 
161
-		foreach( $this->get( 'aimeos' )->get()->getI18nList( 'admin' ) as $id ) {
162
-			$result[] = array( 'id' => $id, 'label' => $id );
161
+		foreach ($this->get('aimeos')->get()->getI18nList('admin') as $id) {
162
+			$result[] = array('id' => $id, 'label' => $id);
163 163
 		}
164 164
 
165
-		return json_encode( $result );
165
+		return json_encode($result);
166 166
 	}
167 167
 
168 168
 
@@ -172,10 +172,10 @@  discard block
 block discarded – undo
172 172
 	 * @param \Aimeos\MShop\Context\Item\Iface $context Context item object
173 173
 	 * @return string JSON encoded configuration object
174 174
 	 */
175
-	protected function getJsonClientConfig( \Aimeos\MShop\Context\Item\Iface $context )
175
+	protected function getJsonClientConfig(\Aimeos\MShop\Context\Item\Iface $context)
176 176
 	{
177
-		$config = $context->getConfig()->get( 'admin/extjs', array() );
178
-		return json_encode( array( 'admin' => array( 'extjs' => $config ) ), JSON_FORCE_OBJECT );
177
+		$config = $context->getConfig()->get('admin/extjs', array());
178
+		return json_encode(array('admin' => array('extjs' => $config)), JSON_FORCE_OBJECT);
179 179
 	}
180 180
 
181 181
 
@@ -186,16 +186,16 @@  discard block
 block discarded – undo
186 186
 	 * @param string $lang ISO language code like "en" or "en_GB"
187 187
 	 * @return string JSON encoded translation object
188 188
 	 */
189
-	protected function getJsonClientI18n( array $i18nPaths, $lang )
189
+	protected function getJsonClientI18n(array $i18nPaths, $lang)
190 190
 	{
191
-		$i18n = new \Aimeos\MW\Translation\Zend2( $i18nPaths, 'gettext', $lang, array( 'disableNotices' => true ) );
191
+		$i18n = new \Aimeos\MW\Translation\Zend2($i18nPaths, 'gettext', $lang, array('disableNotices' => true));
192 192
 
193 193
 		$content = array(
194
-			'admin' => $i18n->getAll( 'admin' ),
195
-			'admin/ext' => $i18n->getAll( 'admin/ext' ),
194
+			'admin' => $i18n->getAll('admin'),
195
+			'admin/ext' => $i18n->getAll('admin/ext'),
196 196
 		);
197 197
 
198
-		return json_encode( $content, JSON_FORCE_OBJECT );
198
+		return json_encode($content, JSON_FORCE_OBJECT);
199 199
 	}
200 200
 
201 201
 
@@ -207,19 +207,19 @@  discard block
 block discarded – undo
207 207
 	 * @return string JSON encoded site item object
208 208
 	 * @throws Exception If no site item was found for the code
209 209
 	 */
210
-	protected function getJsonSiteItem( \Aimeos\MShop\Context\Item\Iface $context, $site )
210
+	protected function getJsonSiteItem(\Aimeos\MShop\Context\Item\Iface $context, $site)
211 211
 	{
212
-		$manager = \Aimeos\MShop\Factory::createManager( $context, 'locale/site' );
212
+		$manager = \Aimeos\MShop\Factory::createManager($context, 'locale/site');
213 213
 
214 214
 		$criteria = $manager->createSearch();
215
-		$criteria->setConditions( $criteria->compare( '==', 'locale.site.code', $site ) );
216
-		$items = $manager->searchItems( $criteria );
215
+		$criteria->setConditions($criteria->compare('==', 'locale.site.code', $site));
216
+		$items = $manager->searchItems($criteria);
217 217
 
218
-		if( ( $item = reset( $items ) ) === false ) {
219
-			throw new \Exception( sprintf( 'No site found for code "%1$s"', $site ) );
218
+		if (($item = reset($items)) === false) {
219
+			throw new \Exception(sprintf('No site found for code "%1$s"', $site));
220 220
 		}
221 221
 
222
-		return json_encode( $item->toArray() );
222
+		return json_encode($item->toArray());
223 223
 	}
224 224
 
225 225
 
@@ -231,17 +231,17 @@  discard block
 block discarded – undo
231 231
 	 * @param string $locale ISO language code, e.g. "en" or "en_GB"
232 232
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
233 233
 	 */
234
-	protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default', $locale = null )
234
+	protected function setLocale(\Aimeos\MShop\Context\Item\Iface $context, $sitecode = 'default', $locale = null)
235 235
 	{
236
-		$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
236
+		$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
237 237
 
238 238
 		try {
239
-			$localeItem = $localeManager->bootstrap( $sitecode, $locale, '', false );
240
-		} catch( \Aimeos\MShop\Locale\Exception $e ) {
239
+			$localeItem = $localeManager->bootstrap($sitecode, $locale, '', false);
240
+		} catch (\Aimeos\MShop\Locale\Exception $e) {
241 241
 			$localeItem = $localeManager->createItem();
242 242
 		}
243 243
 
244
-		$context->setLocale( $localeItem );
244
+		$context->setLocale($localeItem);
245 245
 
246 246
 		return $context;
247 247
 	}
Please login to merge, or discard this patch.
Service/Aimeos.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param Container $container Container object to access parameters
31 31
 	 */
32
-	public function __construct( Container $container )
32
+	public function __construct(Container $container)
33 33
 	{
34 34
 		$this->container = $container;
35 35
 	}
@@ -42,10 +42,10 @@  discard block
 block discarded – undo
42 42
 	 */
43 43
 	public function get()
44 44
 	{
45
-		if( $this->object === null )
45
+		if ($this->object === null)
46 46
 		{
47
-			$extDirs = (array) $this->container->getParameter( 'aimeos_shop.extdir' );
48
-			$this->object = new \Aimeos\Bootstrap( $extDirs, false );
47
+			$extDirs = (array) $this->container->getParameter('aimeos_shop.extdir');
48
+			$this->object = new \Aimeos\Bootstrap($extDirs, false);
49 49
 		}
50 50
 
51 51
 		return $this->object;
@@ -59,14 +59,14 @@  discard block
 block discarded – undo
59 59
 	 */
60 60
 	public function getVersion()
61 61
 	{
62
-		$filename = dirname( $this->container->get( 'kernel' )->getRootDir() ) . DIRECTORY_SEPARATOR . 'composer.lock';
62
+		$filename = dirname($this->container->get('kernel')->getRootDir()) . DIRECTORY_SEPARATOR . 'composer.lock';
63 63
 
64
-		if( file_exists( $filename ) === true && ( $content = file_get_contents( $filename ) ) !== false
65
-			&& ( $content = json_decode( $content, true ) ) !== null && isset( $content['packages'] )
64
+		if (file_exists($filename) === true && ($content = file_get_contents($filename)) !== false
65
+			&& ($content = json_decode($content, true)) !== null && isset($content['packages'])
66 66
 		) {
67
-			foreach( (array) $content['packages'] as $item )
67
+			foreach ((array) $content['packages'] as $item)
68 68
 			{
69
-				if( $item['name'] === 'aimeos/aimeos-symfony' ) {
69
+				if ($item['name'] === 'aimeos/aimeos-symfony') {
70 70
 					return $item['version'];
71 71
 				}
72 72
 			}
Please login to merge, or discard this patch.