本文整理汇总了PHP中Symfony\Component\Console\Application::getHelperSet方法的典型用法代码示例。如果您正苦于以下问题:PHP Application::getHelperSet方法的具体用法?PHP Application::getHelperSet怎么用?PHP Application::getHelperSet使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Application
的用法示例。
在下文中一共展示了Application::getHelperSet方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setApplicationDocumentManager
public static function setApplicationDocumentManager(Application $application, $dmName)
{
$service = null === $dmName ? 'doctrine_phpcr.odm.document_manager' : 'doctrine_phpcr.odm.' . $dmName . '_document_manager';
$documentManager = $application->getKernel()->getContainer()->get($service);
$helperSet = $application->getHelperSet();
$helperSet->set(new DocumentManagerHelper(null, $documentManager));
}
示例2: boot
/**
* Bootstraps the application.
*
* This method is called after all services are registered
* and should be used for "dynamic" configuration (whenever
* a service must be requested).
*
* @param Application $app
*/
public function boot(Application $app)
{
$helperSet = new HelperSet(array('connection' => new ConnectionHelper($app['db']), 'dialog' => new DialogHelper()));
if (isset($app['orm.em'])) {
$helperSet->set(new EntityManagerHelper($app['orm.em']), 'em');
}
$this->console->setHelperSet($helperSet);
$commands = array('Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\ExecuteCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\GenerateCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\MigrateCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\StatusCommand', 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\VersionCommand');
// @codeCoverageIgnoreStart
if (true === $this->console->getHelperSet()->has('em')) {
$commands[] = 'Doctrine\\DBAL\\Migrations\\Tools\\Console\\Command\\DiffCommand';
}
// @codeCoverageIgnoreEnd
$configuration = new Configuration($app['db'], $app['migrations.output_writer']);
$configuration->setMigrationsDirectory($app['migrations.directory']);
$configuration->setName($app['migrations.name']);
$configuration->setMigrationsNamespace($app['migrations.namespace']);
$configuration->setMigrationsTableName($app['migrations.table_name']);
$configuration->registerMigrationsFromDirectory($app['migrations.directory']);
foreach ($commands as $name) {
/** @var AbstractCommand $command */
$command = new $name();
$command->setMigrationConfiguration($configuration);
$this->console->add($command);
}
}
示例3: setApplicationEntityManager
/**
* Convenience method to push the helper sets of a given entity manager into the application.
*
* @param Application $application
* @param string $emName
*/
public static function setApplicationEntityManager(Application $application, $emName)
{
/** @var $em \Doctrine\ORM\EntityManager */
$em = $application->getHelperSet()->get('container')->getContainer()->get('doctrine')->getManager();
$helperSet = $application->getHelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
}
示例4: testValidHelpers
public function testValidHelpers()
{
$helperSet = $this->cli->getHelperSet();
/* @var $dmHelper \Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper */
$dmHelper = $helperSet->get('dm');
$this->assertInstanceOf('\\Doctrine\\ODM\\MongoDB\\Tools\\Console\\Helper\\DocumentManagerHelper', $dmHelper);
$this->assertSame($this->entityManager, $dmHelper->getDocumentManager());
}
示例5: getCommandTester
/**
* @return CommandTester
*/
protected function getCommandTester()
{
$this->application->getHelperSet()->set($this->dialog, 'dialog');
$this->application->add($this->command);
$command = $this->application->find('phpci:create-admin');
$commandTester = new CommandTester($command);
return $commandTester;
}
示例6: getInstance
/**
* Create CLI instance.
*
* @return Application
*/
public static function getInstance()
{
$questionHelper = new QuestionHelper();
$application = new Application('CloverToHtml Command Line Interface', 'Beta 0.1.0');
$application->getHelperSet()->set(new FormatterHelper(), 'formatter');
$application->getHelperSet()->set($questionHelper, 'question');
$application->add(ConvertCommandFactory::getInstance());
return $application;
}
示例7: run
/**
* @param string $input
*
* @return integer
*/
public function run($input)
{
$this->input = new StringInput($input);
$this->output = new StreamOutput(fopen('php://memory', 'w', false));
$inputStream = $this->getInputStream();
rewind($inputStream);
$this->application->getHelperSet()->get('dialog')->setInputStream($inputStream);
$this->result = $this->application->run($this->input, $this->output);
}
示例8: getInstance
/**
* Create CLI instance.
*
* @return \Symfony\Component\Console\Application
*/
public static function getInstance()
{
$questionHelper = new QuestionHelper();
$application = new Application('Code Generator Command Line Interface', 'Alpha');
$application->getHelperSet()->set(new FormatterHelper(), 'formatter');
$application->getHelperSet()->set($questionHelper, 'question');
$application->add(new ConvertDirectory());
return $application;
}
示例9: getInstance
/**
* Create CLI instance.
*
* @return Application
*/
public static function getInstance(OutputInterface $output)
{
$questionHelper = new QuestionHelper();
$application = new Application('PHP to Zephir Command Line Interface', 'Beta 0.2.0');
$application->getHelperSet()->set(new FormatterHelper(), 'formatter');
$application->getHelperSet()->set($questionHelper, 'question');
$application->add(ConvertFactory::getInstance($output));
return $application;
}
示例10: testValidHelpers
public function testValidHelpers()
{
$helperSet = $this->cli->getHelperSet();
/* @var $emHelper \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper */
$emHelper = $helperSet->get('em');
$this->assertInstanceOf('Doctrine\\ORM\\Tools\\Console\\Helper\\EntityManagerHelper', $emHelper);
$this->assertSame($this->entityManager, $emHelper->getEntityManager());
/* @var $dbHelper \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper */
$dbHelper = $helperSet->get('db');
$this->assertInstanceOf('Doctrine\\DBAL\\Tools\\Console\\Helper\\ConnectionHelper', $dbHelper);
$this->assertSame($this->entityManager->getConnection(), $dbHelper->getConnection());
}
示例11: addCommands
/**
* @param Application $cli
*
* @return void
*/
public static function addCommands(Application $cli)
{
$cli->addCommands([new Command\ExecuteCommand(), new Command\GenerateCommand(), new Command\LatestCommand(), new Command\MigrateCommand(), new Command\StatusCommand(), new Command\VersionCommand(), new Command\UpToDateCommand()]);
if ($cli->getHelperSet()->has('em')) {
$cli->add(new Command\DiffCommand());
}
}
示例12: setApplicationConnection
public static function setApplicationConnection(Application $application, $connName)
{
$app = $application->getApp();
$connection = $app['db'];
$helperSet = $application->getHelperSet();
$helperSet->set(new ConnectionHelper($connection), 'db');
}
示例13:
function it_should_wrap_getApplication_in_a_shell(Application $app, HelperSet $helperSet)
{
$app->getHelperSet()->willReturn($helperSet);
$app->getName()->willReturn('test');
$this->setApplication($app);
$shell = $this->getShell();
$shell->shouldHaveType('Symfony\\Component\\Console\\Shell');
}
示例14: initHelper
/**
* @param Application $application
* @param mixed $default
* @param array $options
* @return ConfigurationHelper
*/
public static function initHelper(Application $application, $default = null, array $options = [])
{
$options = $options + ['name' => 'config', 'abbreviation' => 'c', 'description' => 'Path to the configuration file.', 'filename' => 'cli-config.php'];
$helper = new static($options['name'], $options['filename']);
$helper->setDefault($default);
$application->getDefinition()->addOption(new InputOption($options['name'], $options['abbreviation'], InputOption::VALUE_REQUIRED, $options['description']));
$application->getHelperSet()->set($helper);
return $helper;
}
示例15: setApplication
/**
* Sets the application instance for this command.
*
* @param Application $application An Application instance
*
* @api
*/
public function setApplication(Application $application = null)
{
$this->application = $application;
if ($application) {
$this->setHelperSet($application->getHelperSet());
} else {
$this->helperSet = null;
}
}