setCatchExceptions() public method

Sets whether to catch exceptions or not during commands execution.
public setCatchExceptions ( boolean $boolean )
$boolean boolean Whether to catch exceptions or not during commands execution
 /**
  * Setup symfonys consoles application
  * 
  * @return ConsoleApplication
  */
 public function setupConsoleApplication()
 {
     $this->consoleApplication = new ConsoleApplication();
     $this->consoleApplication->setCatchExceptions(false);
     $this->setupConsoleCommands();
     return $this->consoleApplication;
 }
Example #2
0
 /**
  * @param $orm
  */
 public function ormCommands($orm)
 {
     if (is_array($orm) && in_array('doctrine', $orm)) {
         /** @var EntityManager $em */
         $em = Model::orm('doctrine')->getOrm();
         $helperSet = ConsoleRunner::createHelperSet($em);
         $this->cli->setCatchExceptions(true);
         $this->cli->setHelperSet($helperSet);
         ConsoleRunner::addCommands($this->cli);
     }
 }
Example #3
0
 /**
  * Creates console.
  *
  * @param HelperSet $helperSet
  * @param \Symfony\Component\Console\Command\Command[] $commands
  * @return Application
  */
 public function createConsole(HelperSet $helperSet, array $commands)
 {
     $cli = new Application($this->getName(), $this->getVersion());
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     $cli->addCommands($commands);
     return $cli;
 }
 /**
  * Run console with the given helperset.
  *
  * @param \Symfony\Component\Console\Helper\HelperSet $helperSet
  * @return void
  */
 public static function run(HelperSet $helperSet)
 {
     $cli = new Application('Propel Command Line Tool', \PropelCli\Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     self::addCommands($cli);
     $cli->run();
 }
Example #5
0
 /**
  * Run console with the given helperset.
  *
  * @param \Symfony\Component\Console\Helper\HelperSet $helperSet
  * @return void
  */
 public static function run(HelperSet $helperSet)
 {
     $cli = new Application('Doctrine Command Line Interface', \Doctrine\ORM\Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     self::addCommands($cli);
     $cli->run();
 }
 public function run($config)
 {
     $cli = new Application('Schema Roller', Version::VERSION);
     $cli->setCatchExceptions(true);
     self::addHelperSets($cli, $config);
     self::addCommands($cli);
     $cli->run();
 }
Example #7
0
 /**
  * @param HelperSet $helperSet
  * @param array $commands
  */
 public static function run(HelperSet $helperSet, $commands = array())
 {
     $cli = new \Symfony\Component\Console\Application('Malocher EventStore CLI', self::VERSION);
     $cli->setHelperSet($helperSet);
     $cli->setCatchExceptions(true);
     self::addCommands($cli);
     $cli->run();
 }
Example #8
0
 /**
  * Run console with the given helperset.
  *
  * @param \Symfony\Component\Console\Helper\HelperSet $helperSet
  * @param \Symfony\Component\Console\Command\Command[] $commands 
  * @return void
  */
 public static function run($commands = array())
 {
     $cli = new Application('Doctrine to XSD Command Line Interface', "1.0");
     $cli->setCatchExceptions(true);
     self::addCommands($cli);
     $cli->addCommands($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
  */
 public static function createApplication(HelperSet $helperSet, $commands = array())
 {
     $cli = new Application('Doctrine Command Line Interface', Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     self::addCommands($cli);
     $cli->addCommands($commands);
     return $cli;
 }
Example #10
0
 /**
  * Runs console with the given helperset.
  *
  * @param HelperSet                                    $helperSet
  * @param \Symfony\Component\Console\Command\Command[] $commands
  *
  * @return void
  */
 public static function run(HelperSet $helperSet, $commands = array())
 {
     $cli = new Application('PoolDBM Command Line Interface', Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->setHelperSet(new HelperSet($helperSet));
     self::addDefaultCommands($cli);
     $cli->addCommands($commands);
     $cli->run();
 }
Example #11
0
 /**
  * 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
  */
 public static function createApplication(HelperSet $helperSet, $commands = [])
 {
     $cli = new Application('Doctrine Migrations', MigrationsVersion::VERSION());
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     self::addCommands($cli);
     $cli->addCommands($commands);
     return $cli;
 }
Example #12
0
 /**
  * Creates a console application with the given helperset and
  * optional commands.
  *
  * @param HelperSet $helperSet
  * @param \Symfony\Component\Console\Command\Command[] $commands
  *
  * @return Application
  */
 public static function createApplication(HelperSet $helperSet, $commands = [])
 {
     $cli = new Application('Humus Amqp Command Line Interface');
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     self::addCommands($cli);
     $cli->addCommands($commands);
     return $cli;
 }
 /**
  * {@inheritDoc}
  */
 public function register(Application $app)
 {
     $app['console'] = $app->share(function ($app) {
         $consoleApp = new ConsoleApplication();
         // disable swallowing exceptions so they actually get pushed to the logger
         $consoleApp->setCatchExceptions(false);
         return $consoleApp;
     });
 }
 /**
  * Runs console with the given helperset.
  *
  * @param \Symfony\Component\Console\Helper\HelperSet  $helperSet
  * @param \Symfony\Component\Console\Command\Command[] $commands
  *
  * @return void
  */
 public static function run(HelperSet $helperSet, $commands = array(), OutputInterface $output = null)
 {
     $cli = new Application('Doctrine Command Line Interface', Version::VERSION);
     $cli->setCatchExceptions(true);
     $cli->setHelperSet($helperSet);
     $cli->setAutoExit(false);
     $commands = array_merge(self::getDefaultCommands(), $commands);
     $cli->addCommands($commands);
     $cli->run(null, $output);
 }
 /**
  * {@inheritDoc}
  * @return Application
  */
 public function __invoke(ContainerInterface $container, $requestedName, array $options = null)
 {
     $cli = new Application();
     $cli->setName('DoctrineModule Command Line Interface');
     $cli->setVersion(Version::VERSION);
     $cli->setHelperSet(new HelperSet());
     $cli->setCatchExceptions(true);
     $cli->setAutoExit(false);
     // Load commands using event
     $this->getEventManager($container)->trigger('loadCli.post', $cli, array('ServiceManager' => $container));
     return $cli;
 }
 /**
  * {@inheritDoc}
  * @return Application
  */
 public function createService(ServiceLocatorInterface $sl)
 {
     $cli = new Application();
     $cli->setName('DoctrineModule Command Line Interface');
     $cli->setVersion(Version::VERSION);
     $cli->setHelperSet(new HelperSet());
     $cli->setCatchExceptions(true);
     $cli->setAutoExit(false);
     // Load commands using event
     $this->getEventManager($sl)->trigger('loadCli.post', $cli, array('ServiceManager' => $sl));
     return $cli;
 }
Example #17
0
 /**
  * If $catchException, application will render Exception internally.
  * If $autoExit, application will exit in this function.
  */
 public function execute(array $config, $catchException = true, $autoExit = true)
 {
     $application = new Application();
     $application->setCatchExceptions($catchException);
     $application->setAutoExit($autoExit);
     foreach ($config as $command) {
         if (!class_exists($command)) {
             print_r(Command::red("Command Not Found: [{$command}]\n"));
         } else {
             $application->add(new $command());
         }
     }
     $application->run();
 }
 public function register(Application $app)
 {
     if (!isset($app["doctrine.entity_manager"])) {
         throw new \Exception("The Doctrine Command Runner requires the Doctrine Entity Manager to be set.");
     }
     $app["doctrine.command_runner"] = $app->share(function ($app) {
         $em = $app["doctrine.entity_manager"];
         $helperSet = new HelperSet(array('db' => new ConnectionHelper($em->getConnection()), 'em' => new EntityManagerHelper($em)));
         $commandLine = new ConsoleApplication("Silex Doctrine2 Integration Console", 0.01);
         $commandLine->setCatchExceptions(true);
         $commandLine->setHelperSet($helperSet);
         $commandLine->addCommands(array(new \Doctrine\DBAL\Tools\Console\Command\RunSqlCommand(), new \Doctrine\DBAL\Tools\Console\Command\ImportCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\MetadataCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\ResultCommand(), new \Doctrine\ORM\Tools\Console\Command\ClearCache\QueryCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\CreateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\UpdateCommand(), new \Doctrine\ORM\Tools\Console\Command\SchemaTool\DropCommand(), new \Doctrine\ORM\Tools\Console\Command\EnsureProductionSettingsCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertDoctrine1SchemaCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateRepositoriesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateEntitiesCommand(), new \Doctrine\ORM\Tools\Console\Command\GenerateProxiesCommand(), new \Doctrine\ORM\Tools\Console\Command\ConvertMappingCommand(), new \Doctrine\ORM\Tools\Console\Command\RunDqlCommand(), new \Doctrine\ORM\Tools\Console\Command\ValidateSchemaCommand()));
         return $commandLine;
     });
 }
 /**
  * 
  * @param ServiceLocatorInterface $serviceLocator
  * @return Application
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $config = $serviceLocator->get(ConfigHelper::class);
     $commandManager = $serviceLocator->get('CommandManager');
     $commands = array_values($commandManager->getCanonicalNames());
     $application = new Application($config->get('application.name'), $config->get('application.version'));
     foreach ($commands as $command) {
         $application->add($commandManager->get($command));
     }
     $application->setHelperSet(new HelperSet());
     $application->setCatchExceptions(true);
     $application->setAutoExit(false);
     $this->getEventManager($serviceLocator)->trigger('loadCli.post', $application, array('ServiceManager' => $serviceLocator));
     return $application;
 }
Example #20
0
 /**
  * Runs the application using the given HelperSet
  *
  * This method is responsible for creating the console application, adding
  * relevant commands, and running it. Other code is responsible for producing
  * the HelperSet itself (your cli-config.php or bootstrap code), and for
  * calling this method (the actual bin command file).
  *
  * @param HelperSet $helperSet
  * @param Application $application
  * @throws \Doxport\Exception\Exception
  * @return integer 0 if everything went fine, or an error code
  */
 public static function run(HelperSet $helperSet, Application $application = null)
 {
     if (!$helperSet->has('em')) {
         throw new Exception('Helper set passed to Doxport console runner must have an entity manager ("em")');
     }
     if (!$application) {
         $application = new Application('Doxport relational data tool', Version::VERSION);
     }
     $application->setCatchExceptions(true);
     $application->setHelperSet($helperSet);
     $application->add(new ExportCommand());
     $application->add(new DeleteCommand());
     $application->add(new ImportCommand());
     return $application->run();
 }
 /**
  * @param Application $app
  * @return ConsoleApplication
  */
 public function configure(Application $app)
 {
     $app->setCatchExceptions(false);
     if ($this->commandsLoader) {
         $this->commandsLoader->loadCommands($app);
     }
     if ($this->singleStateConfigurator) {
         if (empty($this->eventDispatcher)) {
             throw new \RuntimeException('Dispatcher component required');
         }
         $this->singleStateConfigurator->configureSingleState($this->eventDispatcher);
     }
     if (!empty($this->eventDispatcher)) {
         $app->setDispatcher($this->eventDispatcher);
     }
 }
Example #22
0
 public function run()
 {
     if ($this->stopped) {
         return 0;
     }
     $pid = pcntl_fork();
     if ($pid < 0) {
         $errno = pcntl_get_last_error();
         throw new \RuntimeException("Cannot fork process, error = " . pcntl_strerror($errno));
     } elseif ($pid == 0) {
         // in child process
         $now = time();
         if ($now < $this->nextRun) {
             if ($this->traceEnabled) {
                 mdebug("Will wait %d seconds for next run of %s", $this->nextRun - $now, $this->name);
             }
             sleep($this->nextRun - $now);
         }
         // run using application
         $this->application->setAutoExit(false);
         // we will handle exit on our own
         $this->application->setCatchExceptions(false);
         // we will catch on our own
         try {
             $ret = $this->application->run($this->input, $this->output);
         } catch (\Exception $e) {
             mtrace($e, "Exception while running command {$this->name}", "error");
             $ret = AbstractDaemonSentinelCommand::EXIT_CODE_COMMON_ERROR;
         }
         // Check if we should alert
         if ($ret != AbstractDaemonSentinelCommand::EXIT_CODE_OK && $this->alert) {
             // alert in child process is better, because we can get more trace here
             malert("Daemon command %s failed with exit code = %d", $this->name, $ret);
             exit(AbstractDaemonSentinelCommand::EXIT_CODE_OK);
             // exit OK because alert is already sent
         } else {
             exit($ret);
         }
     } else {
         $this->lastRun = $this->nextRun;
         return $pid;
     }
 }
 /**
  * @param Container
  * @return Application
  */
 public static function createConsole(Container $container, $config)
 {
     $console = new Application($config['name'], $config['version']);
     $helperSet = new HelperSet();
     foreach (array_keys($container->findByTag(self::HELPER_TAG)) as $name) {
         $helperSet->set($container->getService($name), $name);
     }
     $console->setHelperSet($helperSet);
     $console->setCatchExceptions($config['catchExceptions']);
     $commands = [];
     foreach (array_keys($container->findByTag(self::COMMAND_TAG)) as $name) {
         $commands[] = $container->getService($name);
     }
     foreach (array_keys($container->findByTag(self::KDYBY_COMMAND_TAG)) as $name) {
         $commands[] = $container->getService($name);
     }
     $console->addCommands($commands);
     return $console;
 }
 /**
  * Launches a command.
  * If '--process-isolation' parameter is specified the command will be launched as a separate process.
  * In this case you can parameter '--process-timeout' to set the process timeout
  * in seconds. Default timeout is 300 seconds.
  * If '--ignore-errors' parameter is specified any errors are ignored;
  * otherwise, an exception is raises if an error happened.
  *
  * @param string $command
  * @param array $params
  * @return CommandExecutor
  * @throws \RuntimeException if command failed and '--ignore-errors' parameter is not specified
  */
 public function runCommand($command, $params = array())
 {
     $params = array_merge(array('command' => $command), $params);
     if ($this->env && $this->env !== 'dev') {
         $params['--env'] = $this->env;
     }
     $ignoreErrors = false;
     if (array_key_exists('--ignore-errors', $params)) {
         $ignoreErrors = true;
         unset($params['--ignore-errors']);
     }
     if (array_key_exists('--process-isolation', $params)) {
         unset($params['--process-isolation']);
         $pb = new ProcessBuilder();
         $pb->add($this->getPhp())->add($_SERVER['argv'][0]);
         if (array_key_exists('--process-timeout', $params)) {
             $pb->setTimeout($params['--process-timeout']);
             unset($params['--process-timeout']);
         } else {
             $pb->setTimeout($this->defaultTimeout);
         }
         foreach ($params as $name => $val) {
             $this->processParameter($pb, $name, $val);
         }
         $process = $pb->inheritEnvironmentVariables(true)->getProcess();
         $output = $this->output;
         $process->run(function ($type, $data) use($output) {
             $output->write($data);
         });
         $this->lastCommandExitCode = $process->getExitCode();
         // synchronize all data caches
         /*if ($this->dataCacheManager) {
               $this->dataCacheManager->sync();
           }*/
     } else {
         $this->application->setAutoExit(false);
         $this->application->setCatchExceptions(false);
         $this->lastCommandExitCode = $this->application->run(new ArrayInput($params), $this->output);
     }
     $this->processResult($ignoreErrors);
     return $this;
 }
 public function initTool()
 {
     $kernel = $this->container->get('kernel');
     $this->console = new Application($kernel);
     $this->console->setAutoExit(false);
     $this->console->setCatchExceptions(false);
     $this->console->add(new GenerateEntitiesDoctrineCommand());
     $this->console->add(new ConvertMappingDoctrineCommand());
     $self = $this;
     $this->console->register('rm')->setDefinition([new InputArgument('path', InputArgument::REQUIRED)])->setCode(function (InputInterface $input, OutputInterface $output) use($self) {
         $path = $input->getArgument('path');
         $cmd = 'rm -rf ' . $path . ' 2>&1';
         $output->writeln(sprintf('<comment>%s</comment>', $cmd));
         $self->runCmd($cmd, $output);
     });
     $this->console->register('mkdir')->setDefinition([new InputArgument('path', InputArgument::REQUIRED)])->setCode(function (InputInterface $input, OutputInterface $output) use($self) {
         $path = $input->getArgument('path');
         $cmd = 'mkdir ' . $path . ' 2>&1';
         $output->writeln(sprintf('<comment>%s</comment>', $cmd));
         $self->runCmd($cmd, $output);
     });
 }
Example #26
0
 /**
  * @expectedException        \LogicException
  * @expectedExceptionMessage caught
  */
 public function testRunWithExceptionAndDispatcher()
 {
     $application = new Application();
     $application->setDispatcher($this->getDispatcher());
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
         throw new \RuntimeException('foo');
     });
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'foo'));
 }
Example #27
0
 /**
  * @expectedException        \LogicException
  * @expectedExceptionMessage caught
  */
 public function testRunWithErrorAndDispatcher()
 {
     $application = new Application();
     $application->setDispatcher($this->getDispatcher());
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->register('dym')->setCode(function (InputInterface $input, OutputInterface $output) {
         $output->write('dym.');
         throw new \Error('dymerr');
     });
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'dym'));
     $this->assertContains('before.dym.caught.after.', $tester->getDisplay(), 'The PHP Error did not dispached events');
 }
Example #28
0
 public function testRun()
 {
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add($command = new \Foo1Command());
     $_SERVER['argv'] = array('cli.php', 'foo:bar1');
     ob_start();
     $application->run();
     ob_end_clean();
     $this->assertEquals('Symfony\\Component\\Console\\Input\\ArgvInput', get_class($command->input), '->run() creates an ArgvInput by default if none is given');
     $this->assertEquals('Symfony\\Component\\Console\\Output\\ConsoleOutput', get_class($command->output), '->run() creates a ConsoleOutput by default if none is given');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array());
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run1.txt', $this->normalize($tester->getDisplay()), '->run() runs the list command if no argument is passed');
     $tester->run(array('--help' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $this->normalize($tester->getDisplay()), '->run() runs the help command if --help is passed');
     $tester->run(array('-h' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run2.txt', $this->normalize($tester->getDisplay()), '->run() runs the help command if -h is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'list', '--help' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $this->normalize($tester->getDisplay()), '->run() displays the help if --help is passed');
     $tester->run(array('command' => 'list', '-h' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run3.txt', $this->normalize($tester->getDisplay()), '->run() displays the help if -h is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('--ansi' => true));
     $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if --ansi is passed');
     $tester->run(array('-a' => true));
     $this->assertTrue($tester->getOutput()->isDecorated(), '->run() forces color output if -a is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('--version' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $this->normalize($tester->getDisplay()), '->run() displays the program version if --version is passed');
     $tester->run(array('-V' => true));
     $this->assertStringEqualsFile(self::$fixturesPath . '/application_run4.txt', $this->normalize($tester->getDisplay()), '->run() displays the program version if -v is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'list', '--quiet' => true));
     $this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if --quiet is passed');
     $tester->run(array('command' => 'list', '-q' => true));
     $this->assertEquals('', $this->normalize($tester->getDisplay()), '->run() removes all output if -q is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'list', '--verbose' => true));
     $this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is --verbose is passed');
     $tester->run(array('command' => 'list', '-v' => true));
     $this->assertEquals(Output::VERBOSITY_VERBOSE, $tester->getOutput()->getVerbosity(), '->run() sets the output to verbose is -v is passed');
     $application = new Application();
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->add(new \FooCommand());
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'foo:bar', '--no-interaction' => true));
     $this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if --no-interaction is passed');
     $tester->run(array('command' => 'foo:bar', '-n' => true));
     $this->assertEquals("called\n", $this->normalize($tester->getDisplay()), '->run() does not called interact() if -n is passed');
 }
Example #29
0
<?php

/** vendor/bin/doctrine looks for a config/cli-config.php file in the project - so that's why this is here **/
/** If the bootstrap (Aurex.php) sees this variable, don't 'run' the HTTP front-controller **/
$cli = true;
require_once __DIR__ . '/vendor/autoload.php';
require_once __DIR__ . '/web/index.php';
use Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain, Symfony\Component\Console\Application as CliApplication, Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper, Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper, UseAllFive\Command\LoadDataFixturesDoctrineCommand, Doctrine\Common\Annotations\AnnotationRegistry, Doctrine\ORM\Mapping\Driver\AnnotationDriver, Doctrine\Common\Annotations\AnnotationReader, Symfony\Component\Console\Helper\HelperSet, Doctrine\ORM\Mapping\Driver\DatabaseDriver, Doctrine\ORM\Tools\Console\Command, Doctrine\DBAL\Connection, Doctrine\DBAL\Version;
/** @var Connection $db The above bootstrap creates the app object for us */
$db = $aurex['db'];
/** @var Doctrine\ORM\EntityManager $em The entity manager */
$em = $aurex['orm.em'];
$driver = new DatabaseDriver($db->getSchemaManager());
$driver->setNamespace('Aurex\\Application\\Entity\\');
$annotationsFile = __DIR__ . '/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php';
AnnotationRegistry::registerFile($annotationsFile);
$driverChain = new MappingDriverChain();
$driverChain->addDriver(new AnnotationDriver(new AnnotationReader(), [__DIR__ . '/lib/Application/Model/Entity']), 'Aurex\\Application\\Model\\Entity\\');
$em->getConfiguration()->setMetadataDriverImpl($driverChain);
/** @var Symfony\Component\Console\Application $cli */
$cli = new CliApplication('Doctrine Command Line Interface', Version::VERSION);
$cli->setCatchExceptions(true);
$cli->setHelperSet(new HelperSet(['db' => new ConnectionHelper($em->getConnection()), 'em' => new EntityManagerHelper($em)]));
$cli->addCommands([new Command\GenerateRepositoriesCommand(), new Command\GenerateEntitiesCommand(), new Command\ConvertMappingCommand(), new Command\ValidateSchemaCommand(), new Command\SchemaTool\CreateCommand(), new Command\SchemaTool\UpdateCommand(), new Command\GenerateProxiesCommand(), new LoadDataFixturesDoctrineCommand()]);
$cli->run();
Example #30
0
 /**
  * @expectedException        \LogicException
  * @expectedExceptionMessage caught
  */
 public function testRunWithExceptionAndDispatcher()
 {
     if (!class_exists('Symfony\\Component\\EventDispatcher\\EventDispatcher')) {
         $this->markTestSkipped('The "EventDispatcher" component is not available');
     }
     $application = new Application();
     $application->setDispatcher($this->getDispatcher());
     $application->setAutoExit(false);
     $application->setCatchExceptions(false);
     $application->register('foo')->setCode(function (InputInterface $input, OutputInterface $output) {
         throw new \RuntimeException('foo');
     });
     $tester = new ApplicationTester($application);
     $tester->run(array('command' => 'foo'));
 }