/** * @param array $input * * @return integer */ public function run($input = array()) { $this->input = new ArrayInput((array) $input); $this->input->setInteractive(false); $this->output = new StreamOutput(fopen('php://memory', 'r+', false)); $inputStream = $this->getInputStream(); rewind($inputStream); $this->application->getHelperSet()->get('dialog')->setInputStream($inputStream); return $this->application->doRun($this->input, $this->output); }
private function addConsoleHelpers(FrameworkApplication $app) { if (!Util::hasQuestionHelper()) { $helper = $app->getKernel()->getContainer()->get('rj_frontend.console.helper.question_legacy'); $app->getHelperSet()->set($helper, 'question'); } }
/** * @param Symfony\Bundle\FrameworkBundle\Console\Application * @param string $dmName */ public static function setApplicationDocumentManager(Application $application, $dmName) { /** @var $dm \Doctrine\ODM\DocumentManager */ $alias = sprintf("doctrine_mongodb.odm.%s", $dmName); $dm = $application->getKernel()->getContainer()->get($alias); $helperSet = $application->getHelperSet(); $helperSet->set(new DocumentManagerHelper($dm), 'dm'); }
/** * Set the document manager on the application. * * @param Application $application * @param string $dmName */ public static function setApplicationDocumentManager(Application $application, $dmName) { /** @var $registry ManagerRegistry */ $registry = $application->getKernel()->getContainer()->get('doctrine_phpcr'); $documentManager = $registry->getManager($dmName); $helperSet = $application->getHelperSet(); $helperSet->set(new DocumentManagerHelper(null, $documentManager)); }
public static function setApplicationDocumentManager(Application $application, $dmName) { $container = $application->getKernel()->getContainer(); $dmName = $dmName ? $dmName : 'default'; $dmServiceName = sprintf('doctrine.odm.mongodb.%s_document_manager', $dmName); if (!$container->has($dmServiceName)) { throw new \InvalidArgumentException(sprintf('Could not find Doctrine ODM DocumentManager named "%s"', $dmName)); } $dm = $container->get($dmServiceName); $helperSet = $application->getHelperSet(); $helperSet->set(new DocumentManagerHelper($dm), 'dm'); }
public static function setApplicationConnection(Application $application, $connName) { $container = $application->getKernel()->getContainer(); $connName = $connName ? $connName : $container->getParameter('doctrine.dbal.default_connection'); $connServiceName = sprintf('doctrine.dbal.%s_connection', $connName); if (!$container->has($connServiceName)) { throw new \InvalidArgumentException(sprintf('Could not find Doctrine Connection named "%s"', $connName)); } $connection = $container->get($connServiceName); $helperSet = $application->getHelperSet(); $helperSet->set(new ConnectionHelper($connection), 'db'); }
public static function setApplicationXmlEntityManager(Application $application, $xemName) { $container = $application->getKernel()->getContainer(); $xemName = $xemName ? $xemName : 'default'; $xemServiceName = sprintf('doctrine.oxm.%s_xml_entity_manager', $xemName); if (!$container->has($xemServiceName)) { throw new \InvalidArgumentException(sprintf('Could not find Doctrine OXM XmlEntityManager named "%s"', $xemName)); } $xem = $container->get($xemServiceName); $helperSet = $application->getHelperSet(); $helperSet->set(new XmlEntityManagerHelper($xem), 'xem'); }
/** * @dataProvider provideTestCommand * * @param $command * @param $reportFile */ public function testCommand($command, $arguments, $reportFile, $inputStream = null) { $client = static::createClient(); $application = new Application($client->getKernel()); $application->setCatchExceptions(false); $output = new BufferedOutput(); $application->setAutoExit(false); if ($inputStream) { $application->getHelperSet()->get('dialog')->setInputStream($this->getInputStream($inputStream)); } //We push a empty argument that is ignore by the application and we push the command itself array_unshift($arguments, null, $command); $application->run(new ArgvInput($arguments), $output); if ($this->dev) { file_put_contents($reportFile, $this->report($application)); } $this->assertStringEqualsFile($reportFile, $this->report($application)); }
/** * Convenience method to push the helper sets of a given connection into the application. * * @param Application $application * @param string $connName */ public static function setApplicationConnection(Application $application, $connName) { $connection = $application->getKernel()->getContainer()->get('doctrine')->getConnection($connName); $helperSet = $application->getHelperSet(); $helperSet->set(new ConnectionHelper($connection), 'db'); }
public static function setApplicationDocumentManager(Application $application, $dmName) { $dm = $application->getKernel()->getContainer()->get('doctrine_mongodb')->getManager($dmName); $helperSet = $application->getHelperSet(); $helperSet->set(new DocumentManagerHelper($dm), 'dm'); }