@@ -42,18 +42,18 @@ discard block |
||
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,49 +70,49 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function fire() |
72 | 72 | { |
73 | - $ctx = $this->getLaravel()->make( '\Aimeos\Shop\Base\Context' )->get( false, 'backend' ); |
|
74 | - $ctx->setEditor( 'aimeos:setup' ); |
|
73 | + $ctx = $this->getLaravel()->make('\Aimeos\Shop\Base\Context')->get(false, 'backend'); |
|
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 | - if( ( $task = $this->option( 'task' ) ) && is_array( $task ) ) { |
|
100 | - $task = reset( $task ); |
|
99 | + if (($task = $this->option('task')) && is_array($task)) { |
|
100 | + $task = reset($task); |
|
101 | 101 | } |
102 | 102 | |
103 | - switch( $this->option( 'action' ) ) |
|
103 | + switch ($this->option('action')) |
|
104 | 104 | { |
105 | 105 | case 'migrate': |
106 | - $manager->migrate( $task ); |
|
106 | + $manager->migrate($task); |
|
107 | 107 | break; |
108 | 108 | case 'rollback': |
109 | - $manager->rollback( $task ); |
|
109 | + $manager->rollback($task); |
|
110 | 110 | break; |
111 | 111 | case 'clean': |
112 | - $manager->clean( $task ); |
|
112 | + $manager->clean($task); |
|
113 | 113 | break; |
114 | 114 | default: |
115 | - throw new \Exception( sprintf( 'Invalid setup action "%1$s"', $this->option( 'action' ) ) ); |
|
115 | + throw new \Exception(sprintf('Invalid setup action "%1$s"', $this->option('action'))); |
|
116 | 116 | } |
117 | 117 | } |
118 | 118 | |
@@ -125,8 +125,8 @@ discard block |
||
125 | 125 | protected function getArguments() |
126 | 126 | { |
127 | 127 | return array( |
128 | - array( 'site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default' ), |
|
129 | - array( 'tplsite', InputArgument::OPTIONAL, 'Site used as template for creating the new one', 'default' ), |
|
128 | + array('site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default'), |
|
129 | + array('tplsite', InputArgument::OPTIONAL, 'Site used as template for creating the new one', 'default'), |
|
130 | 130 | ); |
131 | 131 | } |
132 | 132 | |
@@ -139,9 +139,9 @@ discard block |
||
139 | 139 | protected function getOptions() |
140 | 140 | { |
141 | 141 | return array( |
142 | - array( 'option', null, InputOption::VALUE_REQUIRED, 'Setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array() ), |
|
143 | - array( 'action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate' ), |
|
144 | - array( 'task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null ), |
|
142 | + array('option', null, InputOption::VALUE_REQUIRED, 'Setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array()), |
|
143 | + array('action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate'), |
|
144 | + array('task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null), |
|
145 | 145 | ); |
146 | 146 | } |
147 | 147 | |
@@ -152,14 +152,14 @@ discard block |
||
152 | 152 | * @param \Aimeos\MW\Config\Iface $conf Config object |
153 | 153 | * @return array Multi-dimensional associative list of database configuration parameters |
154 | 154 | */ |
155 | - protected function getDbConfig( \Aimeos\MW\Config\Iface $conf ) |
|
155 | + protected function getDbConfig(\Aimeos\MW\Config\Iface $conf) |
|
156 | 156 | { |
157 | - $dbconfig = $conf->get( 'resource', array() ); |
|
157 | + $dbconfig = $conf->get('resource', array()); |
|
158 | 158 | |
159 | - foreach( $dbconfig as $rname => $dbconf ) |
|
159 | + foreach ($dbconfig as $rname => $dbconf) |
|
160 | 160 | { |
161 | - if( strncmp( $rname, 'db', 2 ) !== 0 ) { |
|
162 | - unset( $dbconfig[$rname] ); |
|
161 | + if (strncmp($rname, 'db', 2) !== 0) { |
|
162 | + unset($dbconfig[$rname]); |
|
163 | 163 | } |
164 | 164 | } |
165 | 165 | |
@@ -174,12 +174,12 @@ discard block |
||
174 | 174 | * @param array Associative list of database configurations |
175 | 175 | * @throws \RuntimeException If the format of the options is invalid |
176 | 176 | */ |
177 | - protected function setOptions( \Aimeos\MW\Config\Iface $conf ) |
|
177 | + protected function setOptions(\Aimeos\MW\Config\Iface $conf) |
|
178 | 178 | { |
179 | - foreach( (array) $this->option( 'option' ) as $option ) |
|
179 | + foreach ((array) $this->option('option') as $option) |
|
180 | 180 | { |
181 | - list( $name, $value ) = explode( ':', $option ); |
|
182 | - $conf->set( str_replace( '\\', '/', $name ), $value ); |
|
181 | + list($name, $value) = explode(':', $option); |
|
182 | + $conf->set(str_replace('\\', '/', $name), $value); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | } |