diff --git a/src/Console/CommandRunner.php b/src/Console/CommandRunner.php index 2d8fa9e9e5b..1b390520639 100644 --- a/src/Console/CommandRunner.php +++ b/src/Console/CommandRunner.php @@ -155,7 +155,7 @@ public function run(array $argv, ConsoleIo $io = null) /** * Get the shell instance for a given command name * - * @param \Cake\Console\ConsoleIo $io The io wrapper for the created shell class. + * @param \Cake\Console\ConsoleIo $io The IO wrapper for the created shell class. * @param \Cake\Console\CommandCollection $commands The command collection to find the shell in. * @param string $name The command name to find * @return \Cake\Console\Shell @@ -173,7 +173,7 @@ protected function getShell(ConsoleIo $io, CommandCollection $commands, $name) } $instance = $commands->get($name); if (is_string($instance)) { - $instance = new $instance($io); + $instance = $this->createShell($instance, $io); } $instance->setRootName($this->root); if ($instance instanceof CommandCollectionAwareInterface) { @@ -182,4 +182,16 @@ protected function getShell(ConsoleIo $io, CommandCollection $commands, $name) return $instance; } + + /** + * The wrapper for creating shell instances. + * + * @param string $className Shell class name. + * @param \Cake\Console\ConsoleIo $io The IO wrapper for the created shell class. + * @return \Cake\Console\Shell + */ + protected function createShell($className, ConsoleIo $io) + { + return new $className($io); + } }