1
0
mirror of synced 2025-01-09 18:47:10 +03:00

added method to be able to reuse the console application

This commit is contained in:
Andreas Hörnicke 2014-06-24 11:02:24 +02:00
parent d98b4a5124
commit eef32d4372

View File

@ -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;
} }
/** /**