added method to be able to reuse the console application
This commit is contained in:
parent
d98b4a5124
commit
eef32d4372
@ -55,13 +55,29 @@ class ConsoleRunner
|
|||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
static public function run(HelperSet $helperSet, $commands = array())
|
static public function run(HelperSet $helperSet, $commands = array())
|
||||||
|
{
|
||||||
|
$cli = self::createApplication($helperSet, $commands);
|
||||||
|
$cli->run();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a console application with the given helperset and
|
||||||
|
* optional commands.
|
||||||
|
*
|
||||||
|
* @param \Symfony\Component\Console\Helper\HelperSet $helperSet
|
||||||
|
* @param array $commands
|
||||||
|
*
|
||||||
|
* @return \Symfony\Component\Console\Application
|
||||||
|
*/
|
||||||
|
static public function createApplication(HelperSet $helperSet, $commands = array())
|
||||||
{
|
{
|
||||||
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
|
$cli = new Application('Doctrine Command Line Interface', Version::VERSION);
|
||||||
$cli->setCatchExceptions(true);
|
$cli->setCatchExceptions(true);
|
||||||
$cli->setHelperSet($helperSet);
|
$cli->setHelperSet($helperSet);
|
||||||
self::addCommands($cli);
|
self::addCommands($cli);
|
||||||
$cli->addCommands($commands);
|
$cli->addCommands($commands);
|
||||||
$cli->run();
|
|
||||||
|
return $cli;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user