diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-30 09:37:32 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-09-30 09:37:32 +0400 |
commit | a00487b0b841c4b15463b591c7f62176c4b84d15 (patch) | |
tree | 6eb893ce356a4740e044c9cdadaf84ffb2095b9d /core/Console.php | |
parent | 0edef3332289a7cbe54b58084b967907d1086d29 (diff) |
coding style fixes, some PHPStorm inspection fixes, improved readability of code, few refactorings, all as part of our code cleanup strategy
Diffstat (limited to 'core/Console.php')
-rw-r--r-- | core/Console.php | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/core/Console.php b/core/Console.php index 03f9df438d..1f418fc79a 100644 --- a/core/Console.php +++ b/core/Console.php @@ -40,6 +40,7 @@ class Console extends Application { $this->initPiwikHost($input); $this->initConfig($output); + try { self::initPlugins(); } catch(\Exception $e) { @@ -51,18 +52,23 @@ class Console extends Application $commands = $this->getAvailableCommands(); foreach ($commands as $command) { - if (!class_exists($command)) { - Log::warning(sprintf('Cannot add command %s, class does not exist', $command)); - } elseif (!is_subclass_of($command, 'Piwik\Plugin\ConsoleCommand')) { - Log::warning(sprintf('Cannot add command %s, class does not extend Piwik\Plugin\ConsoleCommand', $command)); - } else { - $this->add(new $command); - } + $this->addCommandIfExists($command); } return parent::doRun($input, $output); } + private function addCommandIfExists($command) + { + if (!class_exists($command)) { + Log::warning(sprintf('Cannot add command %s, class does not exist', $command)); + } elseif (!is_subclass_of($command, 'Piwik\Plugin\ConsoleCommand')) { + Log::warning(sprintf('Cannot add command %s, class does not extend Piwik\Plugin\ConsoleCommand', $command)); + } else { + $this->add(new $command); + } + } + /** * Returns a list of available command classnames. * @@ -128,9 +134,11 @@ class Console extends Application protected function initConfig(OutputInterface $output) { $config = Config::getInstance(); + try { $config->checkLocalConfigFound(); return $config; + } catch (\Exception $e) { $output->writeln($e->getMessage() . "\n"); } @@ -151,6 +159,8 @@ class Console extends Application $extra = new \Piwik\Plugins\EnterpriseAdmin\EnterpriseAdmin(); $extra->addConsoleCommands($commands); } + return $commands; } + } |