diff options
author | diosmosis <benaka@piwik.pro> | 2015-03-06 06:26:34 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-03-06 06:26:34 +0300 |
commit | a73225f9c61e3b9cfa6d003daec082d167f2bf4d (patch) | |
tree | 883e5d4b4f1db9ecb4c01544a723c10decc7c56f /core/Console.php | |
parent | 1479c500f04cc921ee93f0ea89d9f8b1505f6fee (diff) |
Do not add command in core/Console.php if command already exists so tests can inject mock commands.
Diffstat (limited to 'core/Console.php')
-rw-r--r-- | core/Console.php | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/core/Console.php b/core/Console.php index de51756f39..d36d7b91a4 100644 --- a/core/Console.php +++ b/core/Console.php @@ -12,6 +12,7 @@ use Piwik\Container\StaticContainer; use Piwik\Plugin\Manager as PluginManager; use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Component\Console\Application; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; @@ -63,10 +64,14 @@ class Console extends Application { if (!class_exists($command)) { Log::warning(sprintf('Cannot add command %s, class does not exist', $command)); - } elseif (!is_subclass_of($command, 'Piwik\Plugin\ConsoleCommand')) { + } else if (!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); + /** @var Command $commandInstance */ + $commandInstance = new $command; + if (!$this->has($commandInstance->getName())) { + $this->add($commandInstance); + } } } |