/** * @return \PhpSpec\Console\Prompter */ public function getPrompter() { if ($this->helperSet->has('question')) { return new Question($this->input, $this->output, $this->helperSet->get('question')); } return new Dialog($this->output, $this->helperSet->get('dialog')); }
/** * read the input and return a Configuration, returns `false` if the config * is not supported * @return Connection|null */ public function chosen() { if ($this->helperSet->has($this->helperName)) { $connectionHelper = $this->helperSet->get($this->helperName); if ($connectionHelper instanceof ConnectionHelper) { return $connectionHelper->getConnection(); } } return null; }
/** * 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(); }
/** * @covers \Symfony\Component\Console\Helper\HelperSet::has */ public function testHas() { $helperset = new HelperSet(array('fake_helper_alias' => $this->getGenericMockHelper('fake_helper'))); $this->assertTrue($helperset->has('fake_helper'), '->has() finds set helper'); $this->assertTrue($helperset->has('fake_helper_alias'), '->has() finds set helper by alias'); }