Skip to content
Extraits de code Groupes Projets
Valider a73225f9 rédigé par diosmosis's avatar diosmosis
Parcourir les fichiers

Do not add command in core/Console.php if command already exists so tests can inject mock commands.

parent 1479c500
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -12,6 +12,7 @@ use Piwik\Container\StaticContainer; ...@@ -12,6 +12,7 @@ use Piwik\Container\StaticContainer;
use Piwik\Plugin\Manager as PluginManager; use Piwik\Plugin\Manager as PluginManager;
use Symfony\Bridge\Monolog\Handler\ConsoleHandler; use Symfony\Bridge\Monolog\Handler\ConsoleHandler;
use Symfony\Component\Console\Application; use Symfony\Component\Console\Application;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
...@@ -63,10 +64,14 @@ class Console extends Application ...@@ -63,10 +64,14 @@ class Console extends Application
{ {
if (!class_exists($command)) { if (!class_exists($command)) {
Log::warning(sprintf('Cannot add command %s, class does not exist', $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)); Log::warning(sprintf('Cannot add command %s, class does not extend Piwik\Plugin\ConsoleCommand', $command));
} else { } else {
$this->add(new $command); /** @var Command $commandInstance */
$commandInstance = new $command;
if (!$this->has($commandInstance->getName())) {
$this->add($commandInstance);
}
} }
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter