Completed
Push — master ( eb1019...577f5a )
by Aimeos
12:30
created
Command/SetupCommand.php 1 patch
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
 	 */
30 30
 	protected function configure()
31 31
 	{
32
-		$this->setName( 'aimeos:setup');
33
-		$this->setDescription( 'Initialize or update the Aimeos database tables' );
34
-		$this->addArgument( 'site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default' );
35
-		$this->addArgument( 'tplsite', InputArgument::OPTIONAL, 'Template site for creating or updating database entries', 'default' );
36
-		$this->addOption( 'option', null, InputOption::VALUE_REQUIRED, 'Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array() );
37
-		$this->addOption( 'action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate' );
38
-		$this->addOption( 'task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null );
32
+		$this->setName('aimeos:setup');
33
+		$this->setDescription('Initialize or update the Aimeos database tables');
34
+		$this->addArgument('site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default');
35
+		$this->addArgument('tplsite', InputArgument::OPTIONAL, 'Template site for creating or updating database entries', 'default');
36
+		$this->addOption('option', null, InputOption::VALUE_REQUIRED, 'Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array());
37
+		$this->addOption('action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate');
38
+		$this->addOption('task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null);
39 39
 	}
40 40
 
41 41
 
@@ -45,41 +45,41 @@  discard block
 block discarded – undo
45 45
 	 * @param InputInterface $input Input object
46 46
 	 * @param OutputInterface $output Output object
47 47
 	 */
48
-	protected function execute( InputInterface $input, OutputInterface $output )
48
+	protected function execute(InputInterface $input, OutputInterface $output)
49 49
 	{
50
-		$ctx = $this->getContainer()->get( 'aimeos_context' )->get( false, 'command' );
51
-		$ctx->setEditor( 'aimeos:setup' );
50
+		$ctx = $this->getContainer()->get('aimeos_context')->get(false, 'command');
51
+		$ctx->setEditor('aimeos:setup');
52 52
 
53 53
 		$config = $ctx->getConfig();
54
-		$site = $input->getArgument( 'site' );
55
-		$tplsite = $input->getArgument( 'tplsite' );
54
+		$site = $input->getArgument('site');
55
+		$tplsite = $input->getArgument('tplsite');
56 56
 
57
-		$config->set( 'setup/site', $site );
58
-		$dbconfig = $this->getDbConfig( $config );
59
-		$this->setOptions( $config, $input );
57
+		$config->set('setup/site', $site);
58
+		$dbconfig = $this->getDbConfig($config);
59
+		$this->setOptions($config, $input);
60 60
 
61
-		$taskPaths = $this->getContainer()->get( 'aimeos' )->get()->getSetupPaths( $tplsite );
62
-		$manager = new \Aimeos\MW\Setup\Manager\Multiple( $ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx );
61
+		$taskPaths = $this->getContainer()->get('aimeos')->get()->getSetupPaths($tplsite);
62
+		$manager = new \Aimeos\MW\Setup\Manager\Multiple($ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx);
63 63
 
64
-		$output->writeln( sprintf( 'Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site ) );
64
+		$output->writeln(sprintf('Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site));
65 65
 
66
-		if( ( $task = $input->getOption( 'task' ) ) && is_array( $task ) ) {
67
-			$task = reset( $task );
66
+		if (($task = $input->getOption('task')) && is_array($task)) {
67
+			$task = reset($task);
68 68
 		}
69 69
 
70
-		switch( $input->getOption( 'action' ) )
70
+		switch ($input->getOption('action'))
71 71
 		{
72 72
 			case 'migrate':
73
-				$manager->migrate( $task );
73
+				$manager->migrate($task);
74 74
 				break;
75 75
 			case 'rollback':
76
-				$manager->rollback( $task );
76
+				$manager->rollback($task);
77 77
 				break;
78 78
 			case 'clean':
79
-				$manager->clean( $task );
79
+				$manager->clean($task);
80 80
 				break;
81 81
 			default:
82
-				throw new \Exception( sprintf( 'Invalid setup action "%1$s"', $input->getOption( 'action' ) ) );
82
+				throw new \Exception(sprintf('Invalid setup action "%1$s"', $input->getOption('action')));
83 83
 		}
84 84
 	}
85 85
 
@@ -90,14 +90,14 @@  discard block
 block discarded – undo
90 90
 	 * @param \Aimeos\MW\Config\Iface $conf Config object
91 91
 	 * @return array Multi-dimensional associative list of database configuration parameters
92 92
 	 */
93
-	protected function getDbConfig( \Aimeos\MW\Config\Iface $conf )
93
+	protected function getDbConfig(\Aimeos\MW\Config\Iface $conf)
94 94
 	{
95
-		$dbconfig = $conf->get( 'resource', array() );
95
+		$dbconfig = $conf->get('resource', array());
96 96
 
97
-		foreach( $dbconfig as $rname => $dbconf )
97
+		foreach ($dbconfig as $rname => $dbconf)
98 98
 		{
99
-			if( strncmp( $rname, 'db', 2 ) !== 0 ) {
100
-				unset( $dbconfig[$rname] );
99
+			if (strncmp($rname, 'db', 2) !== 0) {
100
+				unset($dbconfig[$rname]);
101 101
 			}
102 102
 		}
103 103
 
@@ -113,12 +113,12 @@  discard block
 block discarded – undo
113 113
 	 * @param array Associative list of database configurations
114 114
 	 * @throws \RuntimeException If the format of the options is invalid
115 115
 	 */
116
-	protected function setOptions( \Aimeos\MW\Config\Iface $conf, InputInterface $input )
116
+	protected function setOptions(\Aimeos\MW\Config\Iface $conf, InputInterface $input)
117 117
 	{
118
-		foreach( (array) $input->getOption( 'option' ) as $option )
118
+		foreach ((array) $input->getOption('option') as $option)
119 119
 		{
120
-			list( $name, $value ) = explode( ':', $option );
121
-			$conf->set( str_replace( '\\', '/', $name ), $value );
120
+			list($name, $value) = explode(':', $option);
121
+			$conf->set(str_replace('\\', '/', $name), $value);
122 122
 		}
123 123
 	}
124 124
 }
Please login to merge, or discard this patch.