@@ -30,18 +30,18 @@ discard block |
||
30 | 30 | * @param string $classname Name of the setup task class |
31 | 31 | * @return boolean True if class is found, false if not |
32 | 32 | */ |
33 | - public static function autoload( $classname ) |
|
33 | + public static function autoload($classname) |
|
34 | 34 | { |
35 | - if( strncmp( $classname, 'Aimeos\\MW\\Setup\\Task\\', 21 ) === 0 ) |
|
35 | + if (strncmp($classname, 'Aimeos\\MW\\Setup\\Task\\', 21) === 0) |
|
36 | 36 | { |
37 | - $fileName = substr( $classname, 21 ) . '.php'; |
|
38 | - $paths = explode( PATH_SEPARATOR, get_include_path() ); |
|
37 | + $fileName = substr($classname, 21).'.php'; |
|
38 | + $paths = explode(PATH_SEPARATOR, get_include_path()); |
|
39 | 39 | |
40 | - foreach( $paths as $path ) |
|
40 | + foreach ($paths as $path) |
|
41 | 41 | { |
42 | - $file = $path . DIRECTORY_SEPARATOR . $fileName; |
|
42 | + $file = $path.DIRECTORY_SEPARATOR.$fileName; |
|
43 | 43 | |
44 | - if( file_exists( $file ) === true && ( include_once $file ) !== false ) { |
|
44 | + if (file_exists($file) === true && (include_once $file) !== false) { |
|
45 | 45 | return true; |
46 | 46 | } |
47 | 47 | } |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | */ |
57 | 57 | protected function configure() |
58 | 58 | { |
59 | - $this->setName( 'aimeos:setup'); |
|
60 | - $this->setDescription( 'Initialize or update the Aimeos database tables' ); |
|
61 | - $this->addArgument( 'site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default' ); |
|
62 | - $this->addArgument( 'tplsite', InputArgument::OPTIONAL, 'Template site for creating or updating database entries', 'default' ); |
|
63 | - $this->addOption( 'option', null, InputOption::VALUE_REQUIRED, 'Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array() ); |
|
64 | - $this->addOption( 'action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate' ); |
|
65 | - $this->addOption( 'task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null ); |
|
59 | + $this->setName('aimeos:setup'); |
|
60 | + $this->setDescription('Initialize or update the Aimeos database tables'); |
|
61 | + $this->addArgument('site', InputArgument::OPTIONAL, 'Site for updating database entries', 'default'); |
|
62 | + $this->addArgument('tplsite', InputArgument::OPTIONAL, 'Template site for creating or updating database entries', 'default'); |
|
63 | + $this->addOption('option', null, InputOption::VALUE_REQUIRED, 'Optional setup configuration, name and value are separated by ":" like "setup/default/demo:1"', array()); |
|
64 | + $this->addOption('action', null, InputOption::VALUE_REQUIRED, 'Action name that should be executed, i.e. "migrate", "rollback", "clean"', 'migrate'); |
|
65 | + $this->addOption('task', null, InputOption::VALUE_REQUIRED, 'Name of the setup task that should be executed', null); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -72,51 +72,51 @@ discard block |
||
72 | 72 | * @param InputInterface $input Input object |
73 | 73 | * @param OutputInterface $output Output object |
74 | 74 | */ |
75 | - protected function execute( InputInterface $input, OutputInterface $output ) |
|
75 | + protected function execute(InputInterface $input, OutputInterface $output) |
|
76 | 76 | { |
77 | - $ctx = $this->getContainer()->get( 'aimeos_context' )->get( false, 'backend' ); |
|
78 | - $ctx->setEditor( 'aimeos:setup' ); |
|
77 | + $ctx = $this->getContainer()->get('aimeos_context')->get(false, 'backend'); |
|
78 | + $ctx->setEditor('aimeos:setup'); |
|
79 | 79 | |
80 | 80 | $config = $ctx->getConfig(); |
81 | - $site = $input->getArgument( 'site' ); |
|
82 | - $tplsite = $input->getArgument( 'tplsite' ); |
|
81 | + $site = $input->getArgument('site'); |
|
82 | + $tplsite = $input->getArgument('tplsite'); |
|
83 | 83 | |
84 | - $config->set( 'setup/site', $site ); |
|
85 | - $dbconfig = $this->getDbConfig( $config ); |
|
86 | - $this->setOptions( $config, $input ); |
|
84 | + $config->set('setup/site', $site); |
|
85 | + $dbconfig = $this->getDbConfig($config); |
|
86 | + $this->setOptions($config, $input); |
|
87 | 87 | |
88 | - $taskPaths = $this->getContainer()->get( 'aimeos' )->get()->getSetupPaths( $tplsite ); |
|
88 | + $taskPaths = $this->getContainer()->get('aimeos')->get()->getSetupPaths($tplsite); |
|
89 | 89 | |
90 | 90 | $includePaths = $taskPaths; |
91 | 91 | $includePaths[] = get_include_path(); |
92 | 92 | |
93 | - if( set_include_path( implode( PATH_SEPARATOR, $includePaths ) ) === false ) { |
|
94 | - throw new \Exception( 'Unable to extend include path' ); |
|
93 | + if (set_include_path(implode(PATH_SEPARATOR, $includePaths)) === false) { |
|
94 | + throw new \Exception('Unable to extend include path'); |
|
95 | 95 | } |
96 | 96 | |
97 | - spl_autoload_register( '\Aimeos\ShopBundle\Command\SetupCommand::autoload', true ); |
|
97 | + spl_autoload_register('\Aimeos\ShopBundle\Command\SetupCommand::autoload', true); |
|
98 | 98 | |
99 | - $manager = new \Aimeos\MW\Setup\Manager\Multiple( $ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx ); |
|
99 | + $manager = new \Aimeos\MW\Setup\Manager\Multiple($ctx->getDatabaseManager(), $dbconfig, $taskPaths, $ctx); |
|
100 | 100 | |
101 | - $output->writeln( sprintf( 'Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site ) ); |
|
101 | + $output->writeln(sprintf('Initializing or updating the Aimeos database tables for site <info>%1$s</info>', $site)); |
|
102 | 102 | |
103 | - if( ( $task = $input->getOption( 'task' ) ) && is_array( $task ) ) { |
|
104 | - $task = reset( $task ); |
|
103 | + if (($task = $input->getOption('task')) && is_array($task)) { |
|
104 | + $task = reset($task); |
|
105 | 105 | } |
106 | 106 | |
107 | - switch( $input->getOption( 'action' ) ) |
|
107 | + switch ($input->getOption('action')) |
|
108 | 108 | { |
109 | 109 | case 'migrate': |
110 | - $manager->migrate( $task ); |
|
110 | + $manager->migrate($task); |
|
111 | 111 | break; |
112 | 112 | case 'rollback': |
113 | - $manager->rollback( $task ); |
|
113 | + $manager->rollback($task); |
|
114 | 114 | break; |
115 | 115 | case 'clean': |
116 | - $manager->clean( $task ); |
|
116 | + $manager->clean($task); |
|
117 | 117 | break; |
118 | 118 | default: |
119 | - throw new \Exception( sprintf( 'Invalid setup action "%1$s"', $input->getOption( 'action' ) ) ); |
|
119 | + throw new \Exception(sprintf('Invalid setup action "%1$s"', $input->getOption('action'))); |
|
120 | 120 | } |
121 | 121 | } |
122 | 122 | |
@@ -127,14 +127,14 @@ discard block |
||
127 | 127 | * @param \Aimeos\MW\Config\Iface $conf Config object |
128 | 128 | * @return array Multi-dimensional associative list of database configuration parameters |
129 | 129 | */ |
130 | - protected function getDbConfig( \Aimeos\MW\Config\Iface $conf ) |
|
130 | + protected function getDbConfig(\Aimeos\MW\Config\Iface $conf) |
|
131 | 131 | { |
132 | - $dbconfig = $conf->get( 'resource', array() ); |
|
132 | + $dbconfig = $conf->get('resource', array()); |
|
133 | 133 | |
134 | - foreach( $dbconfig as $rname => $dbconf ) |
|
134 | + foreach ($dbconfig as $rname => $dbconf) |
|
135 | 135 | { |
136 | - if( strncmp( $rname, 'db', 2 ) !== 0 ) { |
|
137 | - unset( $dbconfig[$rname] ); |
|
136 | + if (strncmp($rname, 'db', 2) !== 0) { |
|
137 | + unset($dbconfig[$rname]); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | |
@@ -150,12 +150,12 @@ discard block |
||
150 | 150 | * @param array Associative list of database configurations |
151 | 151 | * @throws \RuntimeException If the format of the options is invalid |
152 | 152 | */ |
153 | - protected function setOptions( \Aimeos\MW\Config\Iface $conf, InputInterface $input ) |
|
153 | + protected function setOptions(\Aimeos\MW\Config\Iface $conf, InputInterface $input) |
|
154 | 154 | { |
155 | - foreach( (array) $input->getOption( 'option' ) as $option ) |
|
155 | + foreach ((array) $input->getOption('option') as $option) |
|
156 | 156 | { |
157 | - list( $name, $value ) = explode( ':', $option ); |
|
158 | - $conf->set( str_replace( '\\', '/', $name ), $value ); |
|
157 | + list($name, $value) = explode(':', $option); |
|
158 | + $conf->set(str_replace('\\', '/', $name), $value); |
|
159 | 159 | } |
160 | 160 | } |
161 | 161 | } |