Completed
Push — master ( 3b843b...fa2058 )
by Aimeos
02:49
created
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.
Controller/JqadmController.php 1 patch
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -30,10 +30,10 @@  discard block
 block discarded – undo
30 30
 	 * @param string $site Unique site code
31 31
 	 * @return Response Generated output
32 32
 	 */
33
-	public function copyAction( Request $request, $resource, $site = 'default' )
33
+	public function copyAction(Request $request, $resource, $site = 'default')
34 34
 	{
35
-		$cntl = $this->createClient( $request, $site, $resource );
36
-		return $this->getHtml( $cntl->copy() );
35
+		$cntl = $this->createClient($request, $site, $resource);
36
+		return $this->getHtml($cntl->copy());
37 37
 	}
38 38
 
39 39
 
@@ -45,10 +45,10 @@  discard block
 block discarded – undo
45 45
 	 * @param string $site Unique site code
46 46
 	 * @return Response Generated output
47 47
 	 */
48
-	public function createAction( Request $request, $resource, $site = 'default' )
48
+	public function createAction(Request $request, $resource, $site = 'default')
49 49
 	{
50
-		$cntl = $this->createClient( $request, $site, $resource );
51
-		return $this->getHtml( $cntl->create() );
50
+		$cntl = $this->createClient($request, $site, $resource);
51
+		return $this->getHtml($cntl->create());
52 52
 	}
53 53
 
54 54
 
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
 	 * @param string $site Unique site code
61 61
 	 * @return Response Generated output
62 62
 	 */
63
-	public function deleteAction( Request $request, $resource, $site = 'default' )
63
+	public function deleteAction(Request $request, $resource, $site = 'default')
64 64
 	{
65
-		$cntl = $this->createClient( $request, $site, $resource );
66
-		return $this->getHtml( $cntl->delete() . $cntl->search() );
65
+		$cntl = $this->createClient($request, $site, $resource);
66
+		return $this->getHtml($cntl->delete() . $cntl->search());
67 67
 	}
68 68
 
69 69
 
@@ -75,10 +75,10 @@  discard block
 block discarded – undo
75 75
 	 * @param string $site Unique site code
76 76
 	 * @return Response Generated output
77 77
 	 */
78
-	public function getAction( Request $request, $resource, $site = 'default' )
78
+	public function getAction(Request $request, $resource, $site = 'default')
79 79
 	{
80
-		$cntl = $this->createClient( $request, $site, $resource );
81
-		return $this->getHtml( $cntl->get() );
80
+		$cntl = $this->createClient($request, $site, $resource);
81
+		return $this->getHtml($cntl->get());
82 82
 	}
83 83
 
84 84
 
@@ -90,10 +90,10 @@  discard block
 block discarded – undo
90 90
 	 * @param string $site Unique site code
91 91
 	 * @return Response Generated output
92 92
 	 */
93
-	public function saveAction( Request $request, $resource, $site = 'default' )
93
+	public function saveAction(Request $request, $resource, $site = 'default')
94 94
 	{
95
-		$cntl = $this->createClient( $request, $site, $resource );
96
-		return $this->getHtml( ( $cntl->save() ? : $cntl->search() ) );
95
+		$cntl = $this->createClient($request, $site, $resource);
96
+		return $this->getHtml(($cntl->save() ?: $cntl->search()));
97 97
 	}
98 98
 
99 99
 
@@ -105,10 +105,10 @@  discard block
 block discarded – undo
105 105
 	 * @param string $site Unique site code
106 106
 	 * @return Response Generated output
107 107
 	 */
108
-	public function searchAction( Request $request, $resource, $site = 'default' )
108
+	public function searchAction(Request $request, $resource, $site = 'default')
109 109
 	{
110
-		$cntl = $this->createClient( $request, $site, $resource );
111
-		return $this->getHtml( $cntl->search() );
110
+		$cntl = $this->createClient($request, $site, $resource);
111
+		return $this->getHtml($cntl->search());
112 112
 	}
113 113
 
114 114
 
@@ -120,20 +120,20 @@  discard block
 block discarded – undo
120 120
 	 * @param string $resource Resource location, e.g. "product"
121 121
 	 * @return \Aimeos\Admin\JQAdm\Iface Context item
122 122
 	 */
123
-	protected function createClient( Request $request, $site, $resource )
123
+	protected function createClient(Request $request, $site, $resource)
124 124
 	{
125
-		$lang = $request->get( 'lang', 'en' );
125
+		$lang = $request->get('lang', 'en');
126 126
 
127
-		$aimeos = $this->get( 'aimeos' )->get();
128
-		$templatePaths = $aimeos->getCustomPaths( 'admin/jqadm/templates' );
127
+		$aimeos = $this->get('aimeos')->get();
128
+		$templatePaths = $aimeos->getCustomPaths('admin/jqadm/templates');
129 129
 
130
-		$context = $this->get( 'aimeos_context' )->get( false );
131
-		$context = $this->setLocale( $context, $site, $lang );
130
+		$context = $this->get('aimeos_context')->get(false);
131
+		$context = $this->setLocale($context, $site, $lang);
132 132
 
133
-		$view = $this->get( 'aimeos_view' )->create( $context->getConfig(), $templatePaths, $lang );
134
-		$context->setView( $view );
133
+		$view = $this->get('aimeos_view')->create($context->getConfig(), $templatePaths, $lang);
134
+		$context->setView($view);
135 135
 
136
-		return \Aimeos\Admin\JQAdm\Factory::createClient( $context, $templatePaths, $resource );
136
+		return \Aimeos\Admin\JQAdm\Factory::createClient($context, $templatePaths, $resource);
137 137
 	}
138 138
 
139 139
 
@@ -143,12 +143,12 @@  discard block
 block discarded – undo
143 143
 	 * @param string $content Content from admin client
144 144
 	 * @return Response View for rendering the output
145 145
 	 */
146
-	protected function getHtml( $content )
146
+	protected function getHtml($content)
147 147
 	{
148
-		$version = $this->get( 'aimeos' )->getVersion();
149
-		$content = str_replace( array( '{type}', '{version}' ), array( 'Symfony', $version ), $content );
148
+		$version = $this->get('aimeos')->getVersion();
149
+		$content = str_replace(array('{type}', '{version}'), array('Symfony', $version), $content);
150 150
 
151
-		return $this->render( 'AimeosShopBundle:Jqadm:index.html.twig', array( 'content' => $content ) );
151
+		return $this->render('AimeosShopBundle:Jqadm:index.html.twig', array('content' => $content));
152 152
 	}
153 153
 
154 154
 
@@ -160,23 +160,23 @@  discard block
 block discarded – undo
160 160
 	 * @param string $lang ISO language code, e.g. "en" or "en_GB"
161 161
 	 * @return \Aimeos\MShop\Context\Item\Iface Modified context object
162 162
 	 */
163
-	protected function setLocale( \Aimeos\MShop\Context\Item\Iface $context, $site, $lang )
163
+	protected function setLocale(\Aimeos\MShop\Context\Item\Iface $context, $site, $lang)
164 164
 	{
165
-		$localeManager = \Aimeos\MShop\Factory::createManager( $context, 'locale' );
165
+		$localeManager = \Aimeos\MShop\Factory::createManager($context, 'locale');
166 166
 
167 167
 		try
168 168
 		{
169
-			$localeItem = $localeManager->bootstrap( $site, '', '', false );
170
-			$localeItem->setLanguageId( null );
171
-			$localeItem->setCurrencyId( null );
169
+			$localeItem = $localeManager->bootstrap($site, '', '', false);
170
+			$localeItem->setLanguageId(null);
171
+			$localeItem->setCurrencyId(null);
172 172
 		}
173
-		catch( \Aimeos\MShop\Locale\Exception $e )
173
+		catch (\Aimeos\MShop\Locale\Exception $e)
174 174
 		{
175 175
 			$localeItem = $localeManager->createItem();
176 176
 		}
177 177
 
178
-		$context->setLocale( $localeItem );
179
-		$context->setI18n( $this->get( 'aimeos_i18n' )->get( array( $lang, 'en' ) ) );
178
+		$context->setLocale($localeItem);
179
+		$context->setI18n($this->get('aimeos_i18n')->get(array($lang, 'en')));
180 180
 
181 181
 		return $context;
182 182
 	}
Please login to merge, or discard this patch.
Tests/Controller/ExtadmControllerTest.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -12,12 +12,12 @@  discard block
 block discarded – undo
12 12
 		$client = static::createClient(array(), array(
13 13
 			'PHP_AUTH_USER' => 'admin',
14 14
 			'PHP_AUTH_PW'   => 'adminpass',
15
-		) );
16
-		$crawler = $client->request( 'GET', '/unittest/extadm/de/0' );
15
+		));
16
+		$crawler = $client->request('GET', '/unittest/extadm/de/0');
17 17
 
18
-		$this->assertEquals( 200, $client->getResponse()->getStatusCode() );
19
-		$this->assertEquals( 1, $crawler->filter( 'head:contains("/{site}/extadm/{lang}/{tab}")' )->count() );
20
-		$this->assertEquals( 1, $crawler->filter( 'body:contains("You need to enable javascript!")' )->count() );
18
+		$this->assertEquals(200, $client->getResponse()->getStatusCode());
19
+		$this->assertEquals(1, $crawler->filter('head:contains("/{site}/extadm/{lang}/{tab}")')->count());
20
+		$this->assertEquals(1, $crawler->filter('body:contains("You need to enable javascript!")')->count());
21 21
 	}
22 22
 
23 23
 
@@ -26,17 +26,17 @@  discard block
 block discarded – undo
26 26
 		$client = static::createClient(array(), array(
27 27
 			'PHP_AUTH_USER' => 'admin',
28 28
 			'PHP_AUTH_PW'   => 'adminpass',
29
-		) );
29
+		));
30 30
 
31
-		$token = $client->getContainer()->get( 'security.csrf.token_manager' )->getToken( 'aimeos_admin_token' );
31
+		$token = $client->getContainer()->get('security.csrf.token_manager')->getToken('aimeos_admin_token');
32 32
 
33
-		$client->request( 'POST', '/unittest/extadm/do?_token=' . $token->getValue(),
33
+		$client->request('POST', '/unittest/extadm/do?_token=' . $token->getValue(),
34 34
 			array(), array(), array('CONTENT_TYPE' => 'application/json'),
35 35
 			'[{"jsonrpc":"2.0","method":"Product_Type.searchItems","params":{"site":"unittest"},"id":2}]'
36 36
 		);
37 37
 
38
-		$this->assertEquals( 200, $client->getResponse()->getStatusCode() );
39
-		$this->assertStringStartsWith( '{', $client->getResponse()->getContent() );
38
+		$this->assertEquals(200, $client->getResponse()->getStatusCode());
39
+		$this->assertStringStartsWith('{', $client->getResponse()->getContent());
40 40
 	}
41 41
 
42 42
 
@@ -45,11 +45,11 @@  discard block
 block discarded – undo
45 45
 		$client = static::createClient(array(), array(
46 46
 			'PHP_AUTH_USER' => 'admin',
47 47
 			'PHP_AUTH_PW'   => 'adminpass',
48
-		) );
48
+		));
49 49
 
50
-		$client->request( 'GET', '/unittest/extadm/file' );
50
+		$client->request('GET', '/unittest/extadm/file');
51 51
 
52
-		$this->assertEquals( 200, $client->getResponse()->getStatusCode() );
53
-		$this->assertContains( 'Ext.', $client->getResponse()->getContent() );
52
+		$this->assertEquals(200, $client->getResponse()->getStatusCode());
53
+		$this->assertContains('Ext.', $client->getResponse()->getContent());
54 54
 	}
55 55
 }
Please login to merge, or discard this patch.
Controller/AccountController.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,8 +29,8 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	public function indexAction()
31 31
 	{
32
-		$params = $this->get( 'aimeos_page' )->getSections( 'account-index' );
33
-		return $this->render( 'AimeosShopBundle:Account:index.html.twig', $params );
32
+		$params = $this->get('aimeos_page')->getSections('account-index');
33
+		return $this->render('AimeosShopBundle:Account:index.html.twig', $params);
34 34
 	}
35 35
 
36 36
 
@@ -44,14 +44,14 @@  discard block
 block discarded – undo
44 44
 		$context = $this->container->get('aimeos_context')->get();
45 45
 		$langid = $context->getLocale()->getLanguageId();
46 46
 
47
-		$view = $this->container->get('aimeos_view')->create( $context->getConfig(), array(), $langid );
48
-		$context->setView( $view );
47
+		$view = $this->container->get('aimeos_view')->create($context->getConfig(), array(), $langid);
48
+		$context->setView($view);
49 49
 
50
-		$client = \Aimeos\Client\Html\Factory::createClient( $context, array(), 'account/download' );
51
-		$client->setView( $view );
50
+		$client = \Aimeos\Client\Html\Factory::createClient($context, array(), 'account/download');
51
+		$client->setView($view);
52 52
 		$client->process();
53 53
 
54 54
 		$response = $view->response();
55
-		return new Response( (string) $response->getBody(), $response->getStatusCode(), $response->getHeaders() );
55
+		return new Response((string) $response->getBody(), $response->getStatusCode(), $response->getHeaders());
56 56
 	}
57 57
 }
Please login to merge, or discard this patch.
Service/View.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
 	 * @param RequestStack $requestStack Current request stack
33 33
 	 * @param Container $container Container object to access parameters
34 34
 	 */
35
-	public function __construct( RequestStack $requestStack, Container $container )
35
+	public function __construct(RequestStack $requestStack, Container $container)
36 36
 	{
37 37
 		$this->requestStack = $requestStack;
38 38
 		$this->container = $container;
@@ -47,56 +47,56 @@  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, array $templatePaths, $locale = null )
50
+	public function create(\Aimeos\MW\Config\Iface $config, array $templatePaths, $locale = null)
51 51
 	{
52 52
 		$params = $fixed = array();
53 53
 		$request = $this->requestStack->getMasterRequest();
54 54
 
55
-		if( $locale !== null )
55
+		if ($locale !== null)
56 56
 		{
57
-			$params = $request->request->all() + $request->query->all() + $request->attributes->get( '_route_params' );
57
+			$params = $request->request->all() + $request->query->all() + $request->attributes->get('_route_params');
58 58
 			$fixed = $this->getFixedParams();
59 59
 
60
-			$i18n = $this->container->get('aimeos_i18n')->get( array( $locale ) );
60
+			$i18n = $this->container->get('aimeos_i18n')->get(array($locale));
61 61
 			$translation = $i18n[$locale];
62 62
 		}
63 63
 		else
64 64
 		{
65
-			$translation = new \Aimeos\MW\Translation\None( 'en' );
65
+			$translation = new \Aimeos\MW\Translation\None('en');
66 66
 		}
67 67
 
68 68
 
69
-		$view = new \Aimeos\MW\View\Standard( $templatePaths );
69
+		$view = new \Aimeos\MW\View\Standard($templatePaths);
70 70
 
71
-		$helper = new \Aimeos\MW\View\Helper\Translate\Standard( $view, $translation );
72
-		$view->addHelper( 'translate', $helper );
71
+		$helper = new \Aimeos\MW\View\Helper\Translate\Standard($view, $translation);
72
+		$view->addHelper('translate', $helper);
73 73
 
74
-		$helper = new \Aimeos\MW\View\Helper\Url\Symfony2( $view, $this->container->get( 'router' ), $fixed );
75
-		$view->addHelper( 'url', $helper );
74
+		$helper = new \Aimeos\MW\View\Helper\Url\Symfony2($view, $this->container->get('router'), $fixed);
75
+		$view->addHelper('url', $helper);
76 76
 
77
-		$helper = new \Aimeos\MW\View\Helper\Param\Standard( $view, $params );
78
-		$view->addHelper( 'param', $helper );
77
+		$helper = new \Aimeos\MW\View\Helper\Param\Standard($view, $params);
78
+		$view->addHelper('param', $helper);
79 79
 
80
-		$helper = new \Aimeos\MW\View\Helper\Config\Standard( $view, $config );
81
-		$view->addHelper( 'config', $helper );
80
+		$helper = new \Aimeos\MW\View\Helper\Config\Standard($view, $config);
81
+		$view->addHelper('config', $helper);
82 82
 
83
-		$sepDec = $config->get( 'client/html/common/format/seperatorDecimal', '.' );
84
-		$sep1000 = $config->get( 'client/html/common/format/seperator1000', ' ' );
85
-		$helper = new \Aimeos\MW\View\Helper\Number\Standard( $view, $sepDec, $sep1000 );
86
-		$view->addHelper( 'number', $helper );
83
+		$sepDec = $config->get('client/html/common/format/seperatorDecimal', '.');
84
+		$sep1000 = $config->get('client/html/common/format/seperator1000', ' ');
85
+		$helper = new \Aimeos\MW\View\Helper\Number\Standard($view, $sepDec, $sep1000);
86
+		$view->addHelper('number', $helper);
87 87
 
88
-		if( $request !== null )
88
+		if ($request !== null)
89 89
 		{
90
-			$helper = new \Aimeos\MW\View\Helper\Request\Symfony2( $view, $request );
91
-			$view->addHelper( 'request', $helper );
90
+			$helper = new \Aimeos\MW\View\Helper\Request\Symfony2($view, $request);
91
+			$view->addHelper('request', $helper);
92 92
 		}
93 93
 
94
-		$helper = new \Aimeos\MW\View\Helper\Response\Symfony2( $view );
95
-		$view->addHelper( 'response', $helper );
94
+		$helper = new \Aimeos\MW\View\Helper\Response\Symfony2($view);
95
+		$view->addHelper('response', $helper);
96 96
 
97
-		$token = $this->container->get( 'security.csrf.token_manager' )->getToken( '_token' );
98
-		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard( $view, '_token', $token->getValue() );
99
-		$view->addHelper( 'csrf', $helper );
97
+		$token = $this->container->get('security.csrf.token_manager')->getToken('_token');
98
+		$helper = new \Aimeos\MW\View\Helper\Csrf\Standard($view, '_token', $token->getValue());
99
+		$view->addHelper('csrf', $helper);
100 100
 
101 101
 		return $view;
102 102
 	}
@@ -112,15 +112,15 @@  discard block
 block discarded – undo
112 112
 		$urlparams = array();
113 113
 		$attr = $this->requestStack->getMasterRequest()->attributes;
114 114
 
115
-		if( ( $site = $attr->get( 'site' ) ) !== null ) {
115
+		if (($site = $attr->get('site')) !== null) {
116 116
 			$urlparams['site'] = $site;
117 117
 		}
118 118
 
119
-		if( ( $lang = $attr->get( 'locale' ) ) !== null ) {
119
+		if (($lang = $attr->get('locale')) !== null) {
120 120
 			$urlparams['locale'] = $lang;
121 121
 		}
122 122
 
123
-		if( ( $currency = $attr->get( 'currency' ) ) !== null ) {
123
+		if (($currency = $attr->get('currency')) !== null) {
124 124
 			$urlparams['currency'] = $currency;
125 125
 		}
126 126
 
Please login to merge, or discard this patch.
Tests/Controller/AccountControllerTest.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,17 +10,17 @@
 block discarded – undo
10 10
 	public function testAccount()
11 11
 	{
12 12
 		$client = static::createClient();
13
-		$client->request( 'GET', '/unittest/de/EUR/myaccount' );
13
+		$client->request('GET', '/unittest/de/EUR/myaccount');
14 14
 
15
-		$this->assertContains( 'aimeos account-history', $client->getResponse()->getContent() );
15
+		$this->assertContains('aimeos account-history', $client->getResponse()->getContent());
16 16
 	}
17 17
 
18 18
 
19 19
 	public function testDownload()
20 20
 	{
21 21
 		$client = static::createClient();
22
-		$client->request( 'GET', '/unittest/de/EUR/myaccount/download/0' );
22
+		$client->request('GET', '/unittest/de/EUR/myaccount/download/0');
23 23
 
24
-		$this->assertEquals( 401, $client->getResponse()->getStatusCode() );
24
+		$this->assertEquals(401, $client->getResponse()->getStatusCode());
25 25
 	}
26 26
 }
Please login to merge, or discard this patch.
Command/JobsCommand.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -29,19 +29,19 @@  discard block
 block discarded – undo
29 29
 	protected function configure()
30 30
 	{
31 31
 		$names = '';
32
-		$aimeos = new \Aimeos\Bootstrap( array() );
33
-		$cntlPaths = $aimeos->getCustomPaths( 'controller/jobs' );
34
-		$controllers = \Aimeos\Controller\Jobs\Factory::getControllers( $this->getBareContext(), $aimeos, $cntlPaths );
32
+		$aimeos = new \Aimeos\Bootstrap(array());
33
+		$cntlPaths = $aimeos->getCustomPaths('controller/jobs');
34
+		$controllers = \Aimeos\Controller\Jobs\Factory::getControllers($this->getBareContext(), $aimeos, $cntlPaths);
35 35
 
36
-		foreach( $controllers as $key => $controller ) {
37
-			$names .= str_pad( $key, 30 ) . $controller->getName() . PHP_EOL;
36
+		foreach ($controllers as $key => $controller) {
37
+			$names .= str_pad($key, 30) . $controller->getName() . PHP_EOL;
38 38
 		}
39 39
 
40
-		$this->setName( 'aimeos:jobs' );
41
-		$this->setDescription( 'Executes the job controllers' );
42
-		$this->addArgument( 'jobs', InputArgument::REQUIRED, 'One or more job controller names like "admin/job customer/email/watch"' );
43
-		$this->addArgument( 'site', InputArgument::OPTIONAL, 'Site codes to execute the jobs for like "default unittest" (none for all)' );
44
-		$this->setHelp( "Available jobs are:\n" . $names );
40
+		$this->setName('aimeos:jobs');
41
+		$this->setDescription('Executes the job controllers');
42
+		$this->addArgument('jobs', InputArgument::REQUIRED, 'One or more job controller names like "admin/job customer/email/watch"');
43
+		$this->addArgument('site', InputArgument::OPTIONAL, 'Site codes to execute the jobs for like "default unittest" (none for all)');
44
+		$this->setHelp("Available jobs are:\n" . $names);
45 45
 	}
46 46
 
47 47
 
@@ -51,23 +51,23 @@  discard block
 block discarded – undo
51 51
 	 * @param InputInterface $input Input object
52 52
 	 * @param OutputInterface $output Output object
53 53
 	 */
54
-	protected function execute( InputInterface $input, OutputInterface $output )
54
+	protected function execute(InputInterface $input, OutputInterface $output)
55 55
 	{
56 56
 		$context = $this->getContext();
57
-		$aimeos = $this->getContainer()->get( 'aimeos' )->get();
57
+		$aimeos = $this->getContainer()->get('aimeos')->get();
58 58
 
59
-		$jobs = explode( ' ', $input->getArgument( 'jobs' ) );
60
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context );
59
+		$jobs = explode(' ', $input->getArgument('jobs'));
60
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context);
61 61
 
62
-		foreach( $this->getSiteItems( $context, $input ) as $siteItem )
62
+		foreach ($this->getSiteItems($context, $input) as $siteItem)
63 63
 		{
64
-			$localeItem = $localeManager->bootstrap( $siteItem->getCode(), 'en', '', false );
65
-			$context->setLocale( $localeItem );
64
+			$localeItem = $localeManager->bootstrap($siteItem->getCode(), 'en', '', false);
65
+			$context->setLocale($localeItem);
66 66
 
67
-			$output->writeln( sprintf( 'Executing the Aimeos jobs for "<info>%s</info>"', $siteItem->getCode() ) );
67
+			$output->writeln(sprintf('Executing the Aimeos jobs for "<info>%s</info>"', $siteItem->getCode()));
68 68
 
69
-			foreach( $jobs as $jobname ) {
70
-				\Aimeos\Controller\Jobs\Factory::createController( $context, $aimeos, $jobname )->run();
69
+			foreach ($jobs as $jobname) {
70
+				\Aimeos\Controller\Jobs\Factory::createController($context, $aimeos, $jobname)->run();
71 71
 			}
72 72
 		}
73 73
 	}
@@ -82,15 +82,15 @@  discard block
 block discarded – undo
82 82
 	{
83 83
 		$ctx = new \Aimeos\MShop\Context\Item\Standard();
84 84
 
85
-		$conf = new \Aimeos\MW\Config\PHPArray( array(), array() );
86
-		$ctx->setConfig( $conf );
85
+		$conf = new \Aimeos\MW\Config\PHPArray(array(), array());
86
+		$ctx->setConfig($conf);
87 87
 
88
-		$locale = \Aimeos\MShop\Factory::createManager( $ctx, 'locale' )->createItem();
89
-		$locale->setLanguageId( 'en' );
90
-		$ctx->setLocale( $locale );
88
+		$locale = \Aimeos\MShop\Factory::createManager($ctx, 'locale')->createItem();
89
+		$locale->setLanguageId('en');
90
+		$ctx->setLocale($locale);
91 91
 
92
-		$i18n = new \Aimeos\MW\Translation\None( 'en' );
93
-		$ctx->setI18n( array( 'en' => $i18n ) );
92
+		$i18n = new \Aimeos\MW\Translation\None('en');
93
+		$ctx->setI18n(array('en' => $i18n));
94 94
 
95 95
 		return $ctx;
96 96
 	}
@@ -105,19 +105,19 @@  discard block
 block discarded – undo
105 105
 	{
106 106
 		$container = $this->getContainer();
107 107
 		$aimeos = $container->get('aimeos')->get();
108
-		$context = $container->get( 'aimeos_context' )->get( false );
108
+		$context = $container->get('aimeos_context')->get(false);
109 109
 
110
-		$tmplPaths = $aimeos->getCustomPaths( 'controller/jobs/templates' );
111
-		$tmplPaths = array_merge( $tmplPaths, $aimeos->getCustomPaths( 'client/html/templates' ) );
112
-		$view = $container->get('aimeos_view')->create( $context->getConfig(), $tmplPaths );
110
+		$tmplPaths = $aimeos->getCustomPaths('controller/jobs/templates');
111
+		$tmplPaths = array_merge($tmplPaths, $aimeos->getCustomPaths('client/html/templates'));
112
+		$view = $container->get('aimeos_view')->create($context->getConfig(), $tmplPaths);
113 113
 
114
-		$langManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $context )->getSubManager( 'language' );
115
-		$langids = array_keys( $langManager->searchItems( $langManager->createSearch( true ) ) );
116
-		$i18n = $this->getContainer()->get( 'aimeos_i18n' )->get( $langids );
114
+		$langManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context)->getSubManager('language');
115
+		$langids = array_keys($langManager->searchItems($langManager->createSearch(true)));
116
+		$i18n = $this->getContainer()->get('aimeos_i18n')->get($langids);
117 117
 
118
-		$context->setEditor( 'aimeos:jobs' );
119
-		$context->setView( $view );
120
-		$context->setI18n( $i18n );
118
+		$context->setEditor('aimeos:jobs');
119
+		$context->setView($view);
120
+		$context->setI18n($i18n);
121 121
 
122 122
 		return $context;
123 123
 	}
Please login to merge, or discard this patch.
Service/I18n.php 1 patch
Spacing   +13 added lines, -13 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
 	}
@@ -41,27 +41,27 @@  discard block
 block discarded – undo
41 41
 	 * @param array $languageIds List of two letter ISO language IDs
42 42
 	 * @return \Aimeos\MW\Translation\Interface[] List of translation objects
43 43
 	 */
44
-	public function get( array $languageIds )
44
+	public function get(array $languageIds)
45 45
 	{
46
-		$i18nPaths = $this->container->get( 'aimeos' )->get()->getI18nPaths();
46
+		$i18nPaths = $this->container->get('aimeos')->get()->getI18nPaths();
47 47
 
48
-		foreach( $languageIds as $langid )
48
+		foreach ($languageIds as $langid)
49 49
 		{
50
-			if( !isset( $this->i18n[$langid] ) )
50
+			if (!isset($this->i18n[$langid]))
51 51
 			{
52
-				$i18n = new \Aimeos\MW\Translation\Gettext( $i18nPaths, $langid );
52
+				$i18n = new \Aimeos\MW\Translation\Gettext($i18nPaths, $langid);
53 53
 
54
-				$apc = (bool) $this->container->getParameter( 'aimeos_shop.apc_enable' );
55
-				$prefix = $this->container->getParameter( 'aimeos_shop.apc_prefix' );
54
+				$apc = (bool) $this->container->getParameter('aimeos_shop.apc_enable');
55
+				$prefix = $this->container->getParameter('aimeos_shop.apc_prefix');
56 56
 
57
-				if( function_exists( 'apc_store' ) === true && $apc === true ) {
58
-					$i18n = new \Aimeos\MW\Translation\Decorator\APC( $i18n, $prefix );
57
+				if (function_exists('apc_store') === true && $apc === true) {
58
+					$i18n = new \Aimeos\MW\Translation\Decorator\APC($i18n, $prefix);
59 59
 				}
60 60
 
61
-				$translations = $this->container->getParameter( 'aimeos_shop.i18n' );
61
+				$translations = $this->container->getParameter('aimeos_shop.i18n');
62 62
 
63
-				if( isset( $translations[$langid] ) ) {
64
-					$i18n = new \Aimeos\MW\Translation\Decorator\Memory( $i18n, $translations[$langid] );
63
+				if (isset($translations[$langid])) {
64
+					$i18n = new \Aimeos\MW\Translation\Decorator\Memory($i18n, $translations[$langid]);
65 65
 				}
66 66
 
67 67
 				$this->i18n[$langid] = $i18n;
Please login to merge, or discard this patch.
Composer/ScriptHandler.php 1 patch
Spacing   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -28,18 +28,18 @@  discard block
 block discarded – undo
28 28
 	 * @param CommandEvent $event CommandEvent instance
29 29
 	 * @throws \RuntimeException If an error occured
30 30
 	 */
31
-	public static function setupDatabase( CommandEvent $event )
31
+	public static function setupDatabase(CommandEvent $event)
32 32
 	{
33 33
 		$options = $env = array();
34 34
 
35
-		if( $event->isDevMode() ) {
35
+		if ($event->isDevMode()) {
36 36
 			$options[] = '--option=setup/default/demo:1';
37 37
 		} else {
38 38
 			$env[] = '--env=prod';
39 39
 		}
40 40
 
41
-		self::executeCommand( $event, 'aimeos:setup', $options + $env );
42
-		self::executeCommand( $event, 'aimeos:cache', $env );
41
+		self::executeCommand($event, 'aimeos:setup', $options + $env);
42
+		self::executeCommand($event, 'aimeos:cache', $env);
43 43
 	}
44 44
 
45 45
 
@@ -49,30 +49,30 @@  discard block
 block discarded – undo
49 49
 	 * @param CommandEvent $event CommandEvent instance
50 50
 	 * @throws \RuntimeException If an error occured
51 51
 	 */
52
-	public static function installBundle( CommandEvent $event )
52
+	public static function installBundle(CommandEvent $event)
53 53
 	{
54
-		$event->getIO()->write( 'Installing the Aimeos shop bundle' );
54
+		$event->getIO()->write('Installing the Aimeos shop bundle');
55 55
 
56
-		$options = self::getOptions( $event );
56
+		$options = self::getOptions($event);
57 57
 
58
-		if( !isset( $options['symfony-app-dir'] ) || !is_dir( $options['symfony-app-dir'] ) )
58
+		if (!isset($options['symfony-app-dir']) || !is_dir($options['symfony-app-dir']))
59 59
 		{
60 60
 			$msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available';
61
-			throw new \RuntimeException( sprintf( $msg, 'symfony-app-dir', $options['symfony-app-dir'] ) );
61
+			throw new \RuntimeException(sprintf($msg, 'symfony-app-dir', $options['symfony-app-dir']));
62 62
 		}
63 63
 
64
-		if( !isset( $options['symfony-web-dir'] ) || !is_dir( $options['symfony-web-dir'] ) )
64
+		if (!isset($options['symfony-web-dir']) || !is_dir($options['symfony-web-dir']))
65 65
 		{
66 66
 			$msg = 'An error occurred because the "%1$s" option or the "%2$s" directory isn\'t available';
67
-			throw new \RuntimeException( sprintf( $msg, 'symfony-web-dir', $options['symfony-web-dir'] ) );
67
+			throw new \RuntimeException(sprintf($msg, 'symfony-web-dir', $options['symfony-web-dir']));
68 68
 		}
69 69
 
70
-		self::updateConfigFile( $options['symfony-app-dir'] . '/config/config.yml' );
71
-		self::updateRoutingFile( $options['symfony-app-dir'] . '/config/routing.yml' );
72
-		self::createDirectory( $options['symfony-app-dir'] . '/secure' );
73
-		self::createDirectory( $options['symfony-web-dir'] . '/uploads' );
74
-		self::createDirectory( $options['symfony-web-dir'] . '/preview' );
75
-		self::createDirectory( $options['symfony-web-dir'] . '/files' );
70
+		self::updateConfigFile($options['symfony-app-dir'] . '/config/config.yml');
71
+		self::updateRoutingFile($options['symfony-app-dir'] . '/config/routing.yml');
72
+		self::createDirectory($options['symfony-app-dir'] . '/secure');
73
+		self::createDirectory($options['symfony-web-dir'] . '/uploads');
74
+		self::createDirectory($options['symfony-web-dir'] . '/preview');
75
+		self::createDirectory($options['symfony-web-dir'] . '/files');
76 76
 	}
77 77
 
78 78
 
@@ -82,14 +82,14 @@  discard block
 block discarded – undo
82 82
 	 * @param string $dir Absolute path of the new directory
83 83
 	 * @throws \RuntimeException If directory couldn't be created
84 84
 	 */
85
-	protected static function createDirectory( $dir )
85
+	protected static function createDirectory($dir)
86 86
 	{
87 87
 		$perm = 0755;
88 88
 
89
-		if( !is_dir( $dir ) && !mkdir( $dir, $perm, true ) )
89
+		if (!is_dir($dir) && !mkdir($dir, $perm, true))
90 90
 		{
91 91
 			$msg = 'Unable to create directory "%1$s" with permission "%2$s"';
92
-			throw new \RuntimeException( sprintf( $msg, $dir, $perm ) );
92
+			throw new \RuntimeException(sprintf($msg, $dir, $perm));
93 93
 		}
94 94
 	}
95 95
 
@@ -102,28 +102,28 @@  discard block
 block discarded – undo
102 102
 	 * @param array List of configuration options for the given command
103 103
 	 * @throws \RuntimeException If the command couldn't be executed
104 104
 	 */
105
-	protected static function executeCommand( CommandEvent $event, $cmd, array $options = array() )
105
+	protected static function executeCommand(CommandEvent $event, $cmd, array $options = array())
106 106
 	{
107
-		$php = escapeshellarg( self::getPhp() );
108
-		$console = escapeshellarg( self::getConsoleDir( $event ) . '/console' );
109
-		$cmd = escapeshellarg( $cmd );
107
+		$php = escapeshellarg(self::getPhp());
108
+		$console = escapeshellarg(self::getConsoleDir($event) . '/console');
109
+		$cmd = escapeshellarg($cmd);
110 110
 
111
-		foreach( $options as $key => $option ) {
112
-			$options[$key] = escapeshellarg( $option );
111
+		foreach ($options as $key => $option) {
112
+			$options[$key] = escapeshellarg($option);
113 113
 		}
114 114
 
115
-		if( $event->getIO()->isDecorated() ) {
115
+		if ($event->getIO()->isDecorated()) {
116 116
 			$console .= ' --ansi';
117 117
 		}
118 118
 
119
-		$process = new Process( $php . ' ' . $console . ' ' . $cmd . ' ' . implode( ' ', $options ), null, null, null, 3600 );
119
+		$process = new Process($php . ' ' . $console . ' ' . $cmd . ' ' . implode(' ', $options), null, null, null, 3600);
120 120
 
121
-		$process->run( function( $type, $buffer ) use ( $event ) {
122
-			$event->getIO()->write( $buffer, false );
121
+		$process->run(function($type, $buffer) use ($event) {
122
+			$event->getIO()->write($buffer, false);
123 123
 		} );
124 124
 
125
-		if( !$process->isSuccessful() ) {
126
-			throw new \RuntimeException( sprintf( 'An error occurred when executing the "%s" command', escapeshellarg( $cmd ) ) );
125
+		if (!$process->isSuccessful()) {
126
+			throw new \RuntimeException(sprintf('An error occurred when executing the "%s" command', escapeshellarg($cmd)));
127 127
 		}
128 128
 	}
129 129
 
@@ -136,19 +136,19 @@  discard block
 block discarded – undo
136 136
 	 * @return string The path to the console directory
137 137
 	 * @throws \RuntimeException If console directory couldn't be found
138 138
 	 */
139
-	protected static function getConsoleDir( CommandEvent $event )
139
+	protected static function getConsoleDir(CommandEvent $event)
140 140
 	{
141
-		$options = self::getOptions( $event );
141
+		$options = self::getOptions($event);
142 142
 
143
-		if( isset( $options['symfony-bin-dir'] ) && is_dir( $options['symfony-bin-dir'] ) ) {
143
+		if (isset($options['symfony-bin-dir']) && is_dir($options['symfony-bin-dir'])) {
144 144
 			return $options['symfony-bin-dir'];
145 145
 		}
146 146
 
147
-		if( isset( $options['symfony-app-dir'] ) && is_dir( $options['symfony-app-dir'] ) ) {
147
+		if (isset($options['symfony-app-dir']) && is_dir($options['symfony-app-dir'])) {
148 148
 			return $options['symfony-app-dir'];
149 149
 		}
150 150
 
151
-		throw new \RuntimeException( sprintf( 'Console directory not found. Neither %1$s nor %2$s option exist', 'symfony-app-dir', 'symfony-bin-dir' ) );
151
+		throw new \RuntimeException(sprintf('Console directory not found. Neither %1$s nor %2$s option exist', 'symfony-app-dir', 'symfony-bin-dir'));
152 152
 	}
153 153
 
154 154
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @param CommandEvent $event Command event object
159 159
 	 * @return array Associative list of option keys and values
160 160
 	 */
161
-	protected static function getOptions( CommandEvent $event )
161
+	protected static function getOptions(CommandEvent $event)
162 162
 	{
163 163
 		return $event->getComposer()->getPackage()->getExtra();
164 164
 	}
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 	{
175 175
 		$phpFinder = new PhpExecutableFinder;
176 176
 
177
-		if( !( $phpPath = $phpFinder->find() ) ) {
178
-			throw new \RuntimeException( 'The php executable could not be found, add it to your PATH environment variable and try again' );
177
+		if (!($phpPath = $phpFinder->find())) {
178
+			throw new \RuntimeException('The php executable could not be found, add it to your PATH environment variable and try again');
179 179
 		}
180 180
 
181 181
 		return $phpPath;
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
 	 * @param string $filename Name of the YAML config file
189 189
 	 * @throws \RuntimeException If file is not found
190 190
 	 */
191
-	protected static function updateConfigFile( $filename )
191
+	protected static function updateConfigFile($filename)
192 192
 	{
193
-		if( ( $content = file_get_contents( $filename ) ) === false ) {
194
-			throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) );
193
+		if (($content = file_get_contents($filename)) === false) {
194
+			throw new \RuntimeException(sprintf('File "%1$s" not found', $filename));
195 195
 		}
196 196
 
197
-		if( self::addAsseticBundle( $content ) === true ) {
197
+		if (self::addAsseticBundle($content) === true) {
198 198
 			$fs = new Filesystem();
199
-			$fs->dumpFile( $filename, $content );
199
+			$fs->dumpFile($filename, $content);
200 200
 		}
201 201
 	}
202 202
 
@@ -207,15 +207,15 @@  discard block
 block discarded – undo
207 207
 	 * @param string $filename Name of the YAML config file
208 208
 	 * @throws \RuntimeException If file is not found
209 209
 	 */
210
-	protected static function updateRoutingFile( $filename )
210
+	protected static function updateRoutingFile($filename)
211 211
 	{
212 212
 		$update = false;
213 213
 
214
-		if( ( $content = file_get_contents( $filename ) ) === false ) {
215
-			throw new \RuntimeException( sprintf( 'File "%1$s" not found', $filename ) );
214
+		if (($content = file_get_contents($filename)) === false) {
215
+			throw new \RuntimeException(sprintf('File "%1$s" not found', $filename));
216 216
 		}
217 217
 
218
-		if( strpos( $content, 'aimeos_shop:' ) === false )
218
+		if (strpos($content, 'aimeos_shop:') === false)
219 219
 		{
220 220
 			$content .= "\n" . 'aimeos_shop:
221 221
     resource: "@AimeosShopBundle/Resources/config/routing.yml"
@@ -224,10 +224,10 @@  discard block
 block discarded – undo
224 224
 			$update = true;
225 225
 		}
226 226
 
227
-		if( $update === true )
227
+		if ($update === true)
228 228
 		{
229 229
 			$fs = new Filesystem();
230
-			$fs->dumpFile( $filename, $content );
230
+			$fs->dumpFile($filename, $content);
231 231
 		}
232 232
 	}
233 233
 
@@ -238,14 +238,14 @@  discard block
 block discarded – undo
238 238
 	 * @param string &$content Content of the config.yml file
239 239
 	 * @return boolean True if modified, false if not
240 240
 	 */
241
-	protected static function addAsseticBundle( &$content )
241
+	protected static function addAsseticBundle(&$content)
242 242
 	{
243
-		if( preg_match( "/    bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content ) !== 1 )
243
+		if (preg_match("/    bundles:[ ]*\[.*'AimeosShopBundle'.*\]/", $content) !== 1)
244 244
 		{
245
-			$search = array( "/    bundles:[ ]*\[([^\]]+)\]/", "/    bundles:[ ]*\[([ ]*)\]/" );
246
-			$replace = array( "    bundles: [$1,'AimeosShopBundle']", "    bundles: ['AimeosShopBundle']" );
245
+			$search = array("/    bundles:[ ]*\[([^\]]+)\]/", "/    bundles:[ ]*\[([ ]*)\]/");
246
+			$replace = array("    bundles: [$1,'AimeosShopBundle']", "    bundles: ['AimeosShopBundle']");
247 247
 
248
-			if( ( $content = preg_replace( $search, $replace, $content ) ) !== null ) {
248
+			if (($content = preg_replace($search, $replace, $content)) !== null) {
249 249
 				return true;
250 250
 			}
251 251
 		}
Please login to merge, or discard this patch.