Completed
Push — master ( 96c485...89068a )
by Aimeos
02:47
created
src/Controller/Jsonadm.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -32,15 +32,15 @@  discard block
 block discarded – undo
32 32
 	 * @param array $args Associative list of route parameters
33 33
 	 * @return ResponseInterface $response Modified response object with generated output
34 34
 	 */
35
-	public static function deleteAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
35
+	public static function deleteAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
36 36
 	{
37 37
 		$status = 500;
38 38
 		$header = $request->getHeaders();
39 39
 
40
-		$client = self::createClient( $container, $request, $response, $args );
41
-		$result = $client->delete( (string) $request->getBody(), $header, $status );
40
+		$client = self::createClient($container, $request, $response, $args);
41
+		$result = $client->delete((string) $request->getBody(), $header, $status);
42 42
 
43
-		return self::withResponse( $response, $result, $status, $header );
43
+		return self::withResponse($response, $result, $status, $header);
44 44
 	}
45 45
 
46 46
 
@@ -53,15 +53,15 @@  discard block
 block discarded – undo
53 53
 	 * @param array $args Associative list of route parameters
54 54
 	 * @return ResponseInterface $response Modified response object with generated output
55 55
 	 */
56
-	public static function getAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
56
+	public static function getAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
57 57
 	{
58 58
 		$status = 500;
59 59
 		$header = $request->getHeaders();
60 60
 
61
-		$client = self::createClient( $container, $request, $response, $args );
62
-		$result = $client->get( (string) $request->getBody(), $header, $status );
61
+		$client = self::createClient($container, $request, $response, $args);
62
+		$result = $client->get((string) $request->getBody(), $header, $status);
63 63
 
64
-		return self::withResponse( $response, $result, $status, $header );
64
+		return self::withResponse($response, $result, $status, $header);
65 65
 	}
66 66
 
67 67
 
@@ -74,15 +74,15 @@  discard block
 block discarded – undo
74 74
 	 * @param array $args Associative list of route parameters
75 75
 	 * @return ResponseInterface $response Modified response object with generated output
76 76
 	 */
77
-	public static function patchAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
77
+	public static function patchAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
78 78
 	{
79 79
 		$status = 500;
80 80
 		$header = $request->getHeaders();
81 81
 
82
-		$client = self::createClient( $container, $request, $response, $args );
83
-		$result = $client->patch( (string) $request->getBody(), $header, $status );
82
+		$client = self::createClient($container, $request, $response, $args);
83
+		$result = $client->patch((string) $request->getBody(), $header, $status);
84 84
 
85
-		return self::withResponse( $response, $result, $status, $header );
85
+		return self::withResponse($response, $result, $status, $header);
86 86
 	}
87 87
 
88 88
 
@@ -95,15 +95,15 @@  discard block
 block discarded – undo
95 95
 	 * @param array $args Associative list of route parameters
96 96
 	 * @return ResponseInterface $response Modified response object with generated output
97 97
 	 */
98
-	public static function postAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
98
+	public static function postAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
99 99
 	{
100 100
 		$status = 500;
101 101
 		$header = $request->getHeaders();
102 102
 
103
-		$client = self::createClient( $container, $request, $response, $args );
104
-		$result = $client->post( (string) $request->getBody(), $header, $status );
103
+		$client = self::createClient($container, $request, $response, $args);
104
+		$result = $client->post((string) $request->getBody(), $header, $status);
105 105
 
106
-		return self::withResponse( $response, $result, $status, $header );
106
+		return self::withResponse($response, $result, $status, $header);
107 107
 	}
108 108
 
109 109
 
@@ -116,15 +116,15 @@  discard block
 block discarded – undo
116 116
 	 * @param array $args Associative list of route parameters
117 117
 	 * @return ResponseInterface $response Modified response object with generated output
118 118
 	 */
119
-	public static function putAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
119
+	public static function putAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
120 120
 	{
121 121
 		$status = 500;
122 122
 		$header = $request->getHeaders();
123 123
 
124
-		$client = self::createClient( $container, $request, $response, $args );
125
-		$result = $client->put( (string) $request->getBody(), $header, $status );
124
+		$client = self::createClient($container, $request, $response, $args);
125
+		$result = $client->put((string) $request->getBody(), $header, $status);
126 126
 
127
-		return self::withResponse( $response, $result, $status, $header );
127
+		return self::withResponse($response, $result, $status, $header);
128 128
 	}
129 129
 
130 130
 
@@ -137,15 +137,15 @@  discard block
 block discarded – undo
137 137
 	 * @param array $args Associative list of route parameters
138 138
 	 * @return ResponseInterface $response Modified response object with generated output
139 139
 	 */
140
-	public static function optionsAction( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
140
+	public static function optionsAction(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
141 141
 	{
142 142
 		$status = 500;
143 143
 		$header = $request->getHeaders();
144 144
 
145
-		$client = self::createClient( $container, $request, $response, $args );
146
-		$result = $client->options( (string) $request->getBody(), $header, $status );
145
+		$client = self::createClient($container, $request, $response, $args);
146
+		$result = $client->options((string) $request->getBody(), $header, $status);
147 147
 
148
-		return self::withResponse( $response, $result, $status, $header );
148
+		return self::withResponse($response, $result, $status, $header);
149 149
 	}
150 150
 
151 151
 
@@ -158,21 +158,21 @@  discard block
 block discarded – undo
158 158
 	 * @param array $args Associative list of route parameters
159 159
 	 * @return \Aimeos\Controller\JsonAdm\Iface JSON admin controller
160 160
 	 */
161
-	protected static function createClient( ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args )
161
+	protected static function createClient(ContainerInterface $container, ServerRequestInterface $request, ResponseInterface $response, array $args)
162 162
 	{
163
-		$resource = ( isset( $args['resource'] ) ? $args['resource'] : null );
164
-		$site = ( isset( $args['site'] ) ? $args['site'] : 'default' );
165
-		$lang = ( isset( $args['lang'] ) ? $args['lang'] : 'en' );
163
+		$resource = (isset($args['resource']) ? $args['resource'] : null);
164
+		$site = (isset($args['site']) ? $args['site'] : 'default');
165
+		$lang = (isset($args['lang']) ? $args['lang'] : 'en');
166 166
 
167
-		$templatePaths = $container->get( 'aimeos' )->getCustomPaths( 'admin/jsonadm/templates' );
167
+		$templatePaths = $container->get('aimeos')->getCustomPaths('admin/jsonadm/templates');
168 168
 
169
-		$context = $container->get( 'aimeos_context' )->get( false, $args );
170
-		$context = self::setLocale( $container->get( 'aimeos_i18n' ), $context, $site, $lang );
169
+		$context = $container->get('aimeos_context')->get(false, $args);
170
+		$context = self::setLocale($container->get('aimeos_i18n'), $context, $site, $lang);
171 171
 
172
-		$view = $container->get( 'aimeos_view' )->create( $request, $response, $args, $templatePaths, $lang );
173
-		$context->setView( $view );
172
+		$view = $container->get('aimeos_view')->create($request, $response, $args, $templatePaths, $lang);
173
+		$context->setView($view);
174 174
 
175
-		return \Aimeos\Admin\JsonAdm\Factory::createClient( $context, $templatePaths, $resource );
175
+		return \Aimeos\Admin\JsonAdm\Factory::createClient($context, $templatePaths, $resource);
176 176
 	}
177 177
 
178 178
 
@@ -185,13 +185,13 @@  discard block
 block discarded – undo
185 185
 	 * @param array $header List of HTTP headers
186 186
 	 * @return ResponseInterface $response Populated response object
187 187
 	 */
188
-	protected static function withResponse( ResponseInterface $response, $content, $status, array $header )
188
+	protected static function withResponse(ResponseInterface $response, $content, $status, array $header)
189 189
 	{
190
-		$response->getBody()->write( $content );
191
-		$response = $response->withStatus( $status );
190
+		$response->getBody()->write($content);
191
+		$response = $response->withStatus($status);
192 192
 
193
-		foreach( $header as $key => $value ) {
194
-			$response->withHeader( $key, $value );
193
+		foreach ($header as $key => $value) {
194
+			$response->withHeader($key, $value);
195 195
 		}
196 196
 
197 197
 		return $response;
@@ -207,23 +207,23 @@  discard block
 block discarded – undo
207 207
 	 * @param string $lang ISO language code, e.g. "en" or "en_GB"
208 208
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
209 209
 	 */
210
-	protected static function setLocale( \Aimeos\Slim\Base\I18n $i18n, \Aimeos\MShop\Context\Item\Iface $context, $sitecode, $lang )
210
+	protected static function setLocale(\Aimeos\Slim\Base\I18n $i18n, \Aimeos\MShop\Context\Item\Iface $context, $sitecode, $lang)
211 211
 	{
212
-		$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
212
+		$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
213 213
 
214 214
 		try
215 215
 		{
216
-			$localeItem = $localeManager->bootstrap( $sitecode, '', '', false );
217
-			$localeItem->setLanguageId( null );
218
-			$localeItem->setCurrencyId( null );
216
+			$localeItem = $localeManager->bootstrap($sitecode, '', '', false);
217
+			$localeItem->setLanguageId(null);
218
+			$localeItem->setCurrencyId(null);
219 219
 		}
220
-		catch( \Aimeos\MShop\Locale\Exception $e )
220
+		catch (\Aimeos\MShop\Locale\Exception $e)
221 221
 		{
222 222
 			$localeItem = $localeManager->createItem();
223 223
 		}
224 224
 
225
-		$context->setLocale( $localeItem );
226
-		$context->setI18n( $i18n->get( array( $lang ) ) );
225
+		$context->setLocale($localeItem);
226
+		$context->setI18n($i18n->get(array($lang)));
227 227
 
228 228
 		return $context;
229 229
 	}
Please login to merge, or discard this patch.
src/Bootstrap.php 1 patch
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 	 * @param \Slim\App $app Slim application
28 28
 	 * @param array $settings Multi-dimensional array of configuration settings
29 29
 	 */
30
-	public function __construct( \Slim\App $app, array $settings )
30
+	public function __construct(\Slim\App $app, array $settings)
31 31
 	{
32 32
 		$this->app = $app;
33 33
 		$this->settings = $settings;
@@ -40,16 +40,16 @@  discard block
 block discarded – undo
40 40
 	 * @param string $path Absolute or relative path to the Aimeos route file
41 41
 	 * @return \Aimeos\Slim\Bootstrap Self instance
42 42
 	 */
43
-	public function routes( $path )
43
+	public function routes($path)
44 44
 	{
45 45
 		$app = $this->app;
46 46
 		$settings = $this->settings;
47 47
 
48
-		$config = function( $key, $default ) use ( $settings )
48
+		$config = function($key, $default) use ($settings)
49 49
 		{
50
-			foreach( explode( '/', trim( $key, '/' ) ) as $part )
50
+			foreach (explode('/', trim($key, '/')) as $part)
51 51
 			{
52
-				if( isset( $settings[$part] ) ) {
52
+				if (isset($settings[$part])) {
53 53
 					$settings = $settings[$part];
54 54
 				} else {
55 55
 					return $default;
@@ -71,49 +71,49 @@  discard block
 block discarded – undo
71 71
 	 * @param string $extdir Absolute or relative path to the Aimeos extension directory
72 72
 	 * @return \Aimeos\Slim\Bootstrap Self instance
73 73
 	 */
74
-	public function setup( $extdir = '../ext' )
74
+	public function setup($extdir = '../ext')
75 75
 	{
76 76
 		$settings = $this->settings;
77 77
 		$container = $this->app->getContainer();
78 78
 
79
-		$container['aimeos'] = function( $c ) use ( $extdir ) {
80
-			return new \Aimeos\Bootstrap( (array) $extdir, false );
79
+		$container['aimeos'] = function($c) use ($extdir) {
80
+			return new \Aimeos\Bootstrap((array) $extdir, false);
81 81
 		};
82 82
 
83
-		$container['aimeos_context'] = function( $c ) {
84
-			return new \Aimeos\Slim\Base\Context( $c );
83
+		$container['aimeos_context'] = function($c) {
84
+			return new \Aimeos\Slim\Base\Context($c);
85 85
 		};
86 86
 
87
-		$container['aimeos_i18n'] = function( $c ) {
88
-			return new \Aimeos\Slim\Base\I18n( $c );
87
+		$container['aimeos_i18n'] = function($c) {
88
+			return new \Aimeos\Slim\Base\I18n($c);
89 89
 		};
90 90
 
91
-		$container['aimeos_page'] = function( $c ) {
92
-			return new \Aimeos\Slim\Base\Page( $c );
91
+		$container['aimeos_page'] = function($c) {
92
+			return new \Aimeos\Slim\Base\Page($c);
93 93
 		};
94 94
 
95
-		$container['aimeos_view'] = function( $c ) {
96
-			return new \Aimeos\Slim\Base\View( $c );
95
+		$container['aimeos_view'] = function($c) {
96
+			return new \Aimeos\Slim\Base\View($c);
97 97
 		};
98 98
 
99 99
 
100
-		$container['aimeos_config'] = function( $c ) use ( $settings ) {
100
+		$container['aimeos_config'] = function($c) use ($settings) {
101 101
 
102 102
 			$default = include __DIR__ . DIRECTORY_SEPARATOR . 'aimeos-default.php';
103
-			$settings = array_replace_recursive( $default, $settings );
103
+			$settings = array_replace_recursive($default, $settings);
104 104
 
105
-			$config = new \Aimeos\MW\Config\PHPArray( $settings, $c['aimeos']->getConfigPaths() );
105
+			$config = new \Aimeos\MW\Config\PHPArray($settings, $c['aimeos']->getConfigPaths());
106 106
 
107
-			if( function_exists( 'apc_store' ) === true && $config->get( 'apc_enabled', false ) == true ) {
108
-				$config = new \Aimeos\MW\Config\Decorator\APC( $config, $config->get( 'apc_prefix', 'slim:' ) );
107
+			if (function_exists('apc_store') === true && $config->get('apc_enabled', false) == true) {
108
+				$config = new \Aimeos\MW\Config\Decorator\APC($config, $config->get('apc_prefix', 'slim:'));
109 109
 			}
110 110
 
111 111
 			return $config;
112 112
 		};
113 113
 
114 114
 
115
-		$container['mailer'] = function( $c ) {
116
-			return \Swift_Mailer::newInstance( \Swift_SendmailTransport::newInstance() );
115
+		$container['mailer'] = function($c) {
116
+			return \Swift_Mailer::newInstance(\Swift_SendmailTransport::newInstance());
117 117
 		};
118 118
 
119 119
 		return $this;
@@ -127,14 +127,14 @@  discard block
 block discarded – undo
127 127
 	 */
128 128
 	public static function getVersion()
129 129
 	{
130
-		$basedir = dirname( dirname( dirname( dirname( __DIR__ ) ) ) ) . DIRECTORY_SEPARATOR;
130
+		$basedir = dirname(dirname(dirname(dirname(__DIR__)))) . DIRECTORY_SEPARATOR;
131 131
 
132
-		if( ( $content = @file_get_contents( $basedir . 'composer.lock' ) ) !== false
133
-			&& ( $content = json_decode( $content, true ) ) !== null && isset( $content['packages'] )
132
+		if (($content = @file_get_contents($basedir . 'composer.lock')) !== false
133
+			&& ($content = json_decode($content, true)) !== null && isset($content['packages'])
134 134
 		) {
135
-			foreach( (array) $content['packages'] as $item )
135
+			foreach ((array) $content['packages'] as $item)
136 136
 			{
137
-				if( $item['name'] === 'aimeos/aimeos-slim' ) {
137
+				if ($item['name'] === 'aimeos/aimeos-slim') {
138 138
 					return $item['version'];
139 139
 				}
140 140
 			}
Please login to merge, or discard this patch.