Completed
Push — master ( 736f57...336742 )
by Aimeos
03:04
created
src/Aimeos/Shop/Command/SetupCommand.php 1 patch
Spacing   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -42,18 +42,18 @@  discard block
 block discarded – undo
42 42
 	 * @param string $classname Name of the setup task class
43 43
 	 * @return boolean True if class is found, false if not
44 44
 	 */
45
-	public static function autoload( $classname )
45
+	public static function autoload($classname)
46 46
 	{
47
-		if( strncmp( $classname, 'Aimeos\\MW\\Setup\\Task\\', 21 ) === 0 )
47
+		if (strncmp($classname, 'Aimeos\\MW\\Setup\\Task\\', 21) === 0)
48 48
 		{
49
-			$fileName = substr( $classname, 21 ) . '.php';
50
-			$paths = explode( PATH_SEPARATOR, get_include_path() );
49
+			$fileName = substr($classname, 21).'.php';
50
+			$paths = explode(PATH_SEPARATOR, get_include_path());
51 51
 
52
-			foreach( $paths as $path )
52
+			foreach ($paths as $path)
53 53
 			{
54
-				$file = $path . DIRECTORY_SEPARATOR . $fileName;
54
+				$file = $path.DIRECTORY_SEPARATOR.$fileName;
55 55
 
56
-				if( file_exists( $file ) === true && ( include_once $file ) !== false ) {
56
+				if (file_exists($file) === true && (include_once $file) !== false) {
57 57
 					return true;
58 58
 				}
59 59
 			}
@@ -70,46 +70,46 @@  discard block
 block discarded – undo
70 70
 	 */
71 71
 	public function fire()
72 72
 	{
73
-		$ctx = $this->getLaravel()->make( '\Aimeos\Shop\Base\Context' )->get( false );
74
-		$ctx->setEditor( 'aimeos:setup' );
73
+		$ctx = $this->getLaravel()->make('\Aimeos\Shop\Base\Context')->get(false);
74
+		$ctx->setEditor('aimeos:setup');
75 75
 
76 76
 		$config = $ctx->getConfig();
77
-		$site = $this->argument( 'site' );
78
-		$template = $this->argument( 'tplsite' );
77
+		$site = $this->argument('site');
78
+		$template = $this->argument('tplsite');
79 79
 
80
-		$config->set( 'setup/site', $site );
81
-		$dbconfig = $this->getDbConfig( $config );
82
-		$this->setOptions( $config );
80
+		$config->set('setup/site', $site);
81
+		$dbconfig = $this->getDbConfig($config);
82
+		$this->setOptions($config);
83 83
 
84
-		$taskPaths = $this->getLaravel()->make( '\Aimeos\Shop\Base\Aimeos' )->get()->getSetupPaths( $template );
84
+		$taskPaths = $this->getLaravel()->make('\Aimeos\Shop\Base\Aimeos')->get()->getSetupPaths($template);
85 85
 
86 86
 		$includePaths = $taskPaths;
87 87
 		$includePaths[] = get_include_path();
88 88
 
89
-		if( set_include_path( implode( PATH_SEPARATOR, $includePaths ) ) === false ) {
90
-			throw new \Exception( 'Unable to extend include path' );
89
+		if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) {
90
+			throw new \Exception('Unable to extend include path');
91 91
 		}
92 92
 
93
-		spl_autoload_register( '\Aimeos\Shop\Command\SetupCommand::autoload', true );
93
+		spl_autoload_register('\Aimeos\Shop\Command\SetupCommand::autoload', true);
94 94
 
95
-		$manager = new \Aimeos\MW\Setup\Manager\Multiple( $ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx );
95
+		$manager = new \Aimeos\MW\Setup\Manager\Multiple($ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx);
96 96
 
97
-		$this->info( sprintf( 'Initializing or updating the Aimeos database tables for site "%1$s"', $site ) );
97
+		$this->info(sprintf('Initializing or updating the Aimeos database tables for site "%1$s"', $site));
98 98
 
99
-		$task = $this->option( 'task' );
100
-		switch( $this->option( 'action' ) )
99
+		$task = $this->option('task');
100
+		switch ($this->option('action'))
101 101
 		{
102 102
 			case 'migrate':
103
-				$manager->migrate( $task );
103
+				$manager->migrate($task);
104 104
 				break;
105 105
 			case 'rollback':
106
-				$manager->rollback( $task );
106
+				$manager->rollback($task);
107 107
 				break;
108 108
 			case 'clean':
109
-				$manager->clean( $task );
109
+				$manager->clean($task);
110 110
 				break;
111 111
 			default:
112
-				throw new \Exception( sprintf( 'Invalid setup action "%1$s"', $this->option( 'action' ) ) );
112
+				throw new \Exception(sprintf('Invalid setup action "%1$s"', $this->option('action')));
113 113
 		}
114 114
 	}
115 115
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	protected function getArguments()
123 123
 	{
124 124
 		return array(
125
-			array( 'site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default' ),
126
-			array( 'tplsite', InputArgument::OPTIONAL, 'Site used as template for creating the new one', 'default' ),
125
+			array('site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default'),
126
+			array('tplsite', InputArgument::OPTIONAL, 'Site used as template for creating the new one', 'default'),
127 127
 		);
128 128
 	}
129 129
 
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 	protected function getOptions()
137 137
 	{
138 138
 		return array(
139
-			array( 'option', null, InputOption::VALUE_REQUIRED, 'Setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array() ),
140
-			array( 'action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate' ),
141
-			array( 'task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null ),
139
+			array('option', null, InputOption::VALUE_REQUIRED, 'Setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array()),
140
+			array('action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate'),
141
+			array('task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null),
142 142
 		);
143 143
 	}
144 144
 
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	 * @param \Aimeos\MW\Config\Iface $conf Config object
150 150
 	 * @return array Multi-dimensional associative list of database configuration parameters
151 151
 	 */
152
-	protected function getDbConfig( \Aimeos\MW\Config\Iface $conf )
152
+	protected function getDbConfig(\Aimeos\MW\Config\Iface $conf)
153 153
 	{
154
-		$dbconfig = $conf->get( 'resource', array() );
154
+		$dbconfig = $conf->get('resource', array());
155 155
 
156
-		foreach( $dbconfig as $rname => $dbconf )
156
+		foreach ($dbconfig as $rname => $dbconf)
157 157
 		{
158
-			if( strncmp( $rname, 'db', 2 ) !== 0 ) {
159
-				unset( $dbconfig[$rname] );
158
+			if (strncmp($rname, 'db', 2) !== 0) {
159
+				unset($dbconfig[$rname]);
160 160
 			}
161 161
 		}
162 162
 
@@ -171,12 +171,12 @@  discard block
 block discarded – undo
171 171
 	 * @param array Associative list of database configurations
172 172
 	 * @throws \RuntimeException If the format of the options is invalid
173 173
 	 */
174
-	protected function setOptions( \Aimeos\MW\Config\Iface $conf )
174
+	protected function setOptions(\Aimeos\MW\Config\Iface $conf)
175 175
 	{
176
-		foreach( (array) $this->option( 'option' ) as $option )
176
+		foreach ((array) $this->option('option') as $option)
177 177
 		{
178
-			list( $name, $value ) = explode( ':', $option );
179
-			$conf->set( $name, $value );
178
+			list($name, $value) = explode(':', $option);
179
+			$conf->set($name, $value);
180 180
 		}
181 181
 	}
182 182
 }
Please login to merge, or discard this patch.