Completed
Push — master ( c642b6...38a7a8 )
by Aimeos
02:53
created
src/Command/Jobs.php 1 patch
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -34,28 +34,28 @@  discard block
 block discarded – undo
34 34
 	 *
35 35
 	 * @param array $argv Associative array from $_SERVER['argv']
36 36
 	 */
37
-	public static function run( array $argv )
37
+	public static function run(array $argv)
38 38
 	{
39
-		array_shift( $argv );
40
-		$options = self::getOptions( $argv );
39
+		array_shift($argv);
40
+		$options = self::getOptions($argv);
41 41
 
42
-		if( ( $jobs = array_shift( $argv ) ) === null ) {
42
+		if (($jobs = array_shift($argv)) === null) {
43 43
 			throw new \Aimeos\Slim\Command\Exception();
44 44
 		}
45
-		$sites = array_shift( $argv );
45
+		$sites = array_shift($argv);
46 46
 
47
-		$config = self::getConfig( $options );
47
+		$config = self::getConfig($options);
48 48
 
49
-		$app = new \Slim\App( $config );
50
-		$aimeos = new \Aimeos\Slim\Bootstrap( $app, $config );
51
-		$aimeos->setup( ( isset( $options['extdir'] ) ? $options['extdir'] : './ext' ) )
52
-			->routes( ( isset( $options['routes'] ) ? $options['routes'] : './src/aimeos-routes.php' ) );
49
+		$app = new \Slim\App($config);
50
+		$aimeos = new \Aimeos\Slim\Bootstrap($app, $config);
51
+		$aimeos->setup((isset($options['extdir']) ? $options['extdir'] : './ext'))
52
+			->routes((isset($options['routes']) ? $options['routes'] : './src/aimeos-routes.php'));
53 53
 
54 54
 		$container = $app->getContainer();
55
-		$context = self::getContext( $container );
55
+		$context = self::getContext($container);
56 56
 
57
-		$siteItems = self::getSiteItems( $context, $sites );
58
-		self::execute( $container->get( 'aimeos' ), $context, $siteItems, $jobs );
57
+		$siteItems = self::getSiteItems($context, $sites);
58
+		self::execute($container->get('aimeos'), $context, $siteItems, $jobs);
59 59
 	}
60 60
 
61 61
 
@@ -65,16 +65,16 @@  discard block
 block discarded – undo
65 65
 	 * @param array $options Associative list of given options
66 66
 	 * @return array Multi-dimensional array of configuration settings
67 67
 	 */
68
-	protected static function getConfig( array $options )
68
+	protected static function getConfig(array $options)
69 69
 	{
70 70
 		$config = array();
71 71
 
72
-		if( isset( $options['config'] ) )
72
+		if (isset($options['config']))
73 73
 		{
74
-			foreach( (array) $options['config'] as $path )
74
+			foreach ((array) $options['config'] as $path)
75 75
 			{
76
-				if( is_file( $path ) ) {
77
-					$config = array_replace_recursive( $config, require $path );
76
+				if (is_file($path)) {
77
+					$config = array_replace_recursive($config, require $path);
78 78
 				}
79 79
 			}
80 80
 		}
@@ -89,25 +89,25 @@  discard block
 block discarded – undo
89 89
 	 * @param \Interop\Container\ContainerInterface $container Dependency injection container
90 90
 	 * @return \Aimeos\MShop\Context\Item\Standard Context object
91 91
 	 */
92
-	protected static function getContext( \Interop\Container\ContainerInterface $container )
92
+	protected static function getContext(\Interop\Container\ContainerInterface $container)
93 93
 	{
94
-		$aimeos = $container->get( 'aimeos' );
95
-		$context = $container->get( 'aimeos_context' )->get( false, array(), 'backend' );
94
+		$aimeos = $container->get('aimeos');
95
+		$context = $container->get('aimeos_context')->get(false, array(), 'backend');
96 96
 
97 97
 		$env = \Slim\Http\Environment::mock();
98
-		$request = \Slim\Http\Request::createFromEnvironment( $env );
98
+		$request = \Slim\Http\Request::createFromEnvironment($env);
99 99
 		$response = new \Slim\Http\Response();
100 100
 
101
-		$tmplPaths = $aimeos->getCustomPaths( 'controller/jobs/templates' );
102
-		$view = $container->get( 'aimeos_view' )->create( $context->getConfig(), $request, $response, array(), $tmplPaths );
101
+		$tmplPaths = $aimeos->getCustomPaths('controller/jobs/templates');
102
+		$view = $container->get('aimeos_view')->create($context->getConfig(), $request, $response, array(), $tmplPaths);
103 103
 
104
-		$langManager = \Aimeos\MShop\Factory::createManager( $context, 'locale/language' );
105
-		$langids = array_keys( $langManager->searchItems( $langManager->createSearch( true ) ) );
106
-		$i18n = $container->get( 'aimeos_i18n' )->get( $langids );
104
+		$langManager = \Aimeos\MShop\Factory::createManager($context, 'locale/language');
105
+		$langids = array_keys($langManager->searchItems($langManager->createSearch(true)));
106
+		$i18n = $container->get('aimeos_i18n')->get($langids);
107 107
 
108
-		$context->setEditor( 'aimeos:jobs' );
109
-		$context->setView( $view );
110
-		$context->setI18n( $i18n );
108
+		$context->setEditor('aimeos:jobs');
109
+		$context->setView($view);
110
+		$context->setI18n($i18n);
111 111
 
112 112
 		return $context;
113 113
 	}
@@ -120,19 +120,19 @@  discard block
 block discarded – undo
120 120
 	 * @param \Aimeos\MShop\Context\Item\Iface $ctx Context object
121 121
 	 * @param array $siteItems List of site items implementing \Aimeos\MShop\Locale\Site\Iface
122 122
 	 */
123
-	protected static function execute( \Aimeos\Bootstrap $aimeos, \Aimeos\MShop\Context\Item\Iface $ctx, array $siteItems, $jobs )
123
+	protected static function execute(\Aimeos\Bootstrap $aimeos, \Aimeos\MShop\Context\Item\Iface $ctx, array $siteItems, $jobs)
124 124
 	{
125
-		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager( $ctx );
125
+		$localeManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($ctx);
126 126
 
127
-		foreach( $siteItems as $siteItem )
127
+		foreach ($siteItems as $siteItem)
128 128
 		{
129
-			$localeItem = $localeManager->bootstrap( $siteItem->getCode(), 'en', '', false );
130
-			$ctx->setLocale( $localeItem );
129
+			$localeItem = $localeManager->bootstrap($siteItem->getCode(), 'en', '', false);
130
+			$ctx->setLocale($localeItem);
131 131
 
132
-			printf( "Executing the Aimeos jobs for \"%s\"\n", $siteItem->getCode() );
132
+			printf("Executing the Aimeos jobs for \"%s\"\n", $siteItem->getCode());
133 133
 
134
-			foreach( (array) explode( ' ', $jobs ) as $jobname ) {
135
-				\Aimeos\Controller\Jobs\Factory::createController( $ctx, $aimeos, $jobname )->run();
134
+			foreach ((array) explode(' ', $jobs) as $jobname) {
135
+				\Aimeos\Controller\Jobs\Factory::createController($ctx, $aimeos, $jobname)->run();
136 136
 			}
137 137
 		}
138 138
 	}
Please login to merge, or discard this patch.