Skip to content

Commit

Permalink
Added the wrapper for creating shell instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert Pustułka committed Jul 21, 2017
1 parent 9fcb61a commit b54116d
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Console/CommandRunner.php
Expand Up @@ -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
Expand All @@ -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) {
Expand All @@ -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);
}
}

0 comments on commit b54116d

Please sign in to comment.