本文整理汇总了PHP中Symfony\Component\Console\Helper\HelperSet类的典型用法代码示例。如果您正苦于以下问题:PHP HelperSet类的具体用法?PHP HelperSet怎么用?PHP HelperSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了HelperSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetCommand
public function testGetCommand()
{
$cmd = new Command('foo');
$helperset = new HelperSet();
$helperset->setCommand($cmd);
$this->assertEquals($cmd, $helperset->getCommand(), '->getCommand() retrieves stored command');
}
示例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: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->get('entity_manager');
$helperSet = new HelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
$helperSet->set($this->getHelper('dialog'), 'dialog');
$arguments = array();
if ($input->getArgument('version')) {
$arguments['version'] = $input->getArgument('version');
}
if ($input->getOption('write-sql')) {
$arguments['--write-sql'] = $input->getOption('write-sql');
}
if ($input->getOption('dry-run')) {
$arguments['--dry-run'] = $input->getOption('dry-run');
}
if ($input->getOption('query-time')) {
$arguments['--query-time'] = $input->getOption('query-time');
}
if ($input->getOption('allow-no-migration')) {
$arguments['--allow-no-migration'] = $input->getOption('allow-no-migration');
}
$configDir = $this->get('config')->get('[directories][config_dir]');
$arguments['--configuration'] = $configDir . '/migrations.yml';
$command = new MigrateCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
示例4: execute
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$em = $this->get('entity_manager');
$helperSet = new HelperSet();
$helperSet->set(new ConnectionHelper($em->getConnection()), 'db');
$helperSet->set(new EntityManagerHelper($em), 'em');
$arguments = array();
if ($input->getArgument('version')) {
$arguments['version'] = $input->getArgument('version');
}
if ($input->getOption('add')) {
$arguments['--add'] = $input->getOption('add');
}
if ($input->getOption('delete')) {
$arguments['--delete'] = $input->getOption('delete');
}
if ($input->getOption('all')) {
$arguments['--all'] = $input->getOption('all');
}
if ($input->getOption('range-from')) {
$arguments['--range-from'] = $input->getOption('range-from');
}
if ($input->getOption('range-to')) {
$arguments['--range-to'] = $input->getOption('range-to');
}
$configDir = $this->get('config')->get('[directories][config_dir]');
$arguments['--configuration'] = $configDir . '/migrations.yml';
$command = new VersionCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
示例5: register
/**
* @inheritdoc
*/
public function register()
{
$container = $this->getContainer();
$container->singleton(Services::HELPERSET, function () use($container) {
$helperSet = new HelperSet();
$helperSet->set($container->get(Services::HELPERSET_QUESTION), 'question');
return $helperSet;
})->withArgument(Services::CONFIG);
$container->add(Services::HELPERSET_QUESTION, QuestionHelper::class);
}
示例6:
function it_dumps_field_filters(OutputInterface $output, HelperSet $helperSet, TableHelper $table)
{
$output->writeln(Argument::any())->shouldBeCalled();
$helperSet->get('table')->willReturn($table);
$headers = ['field', 'filter_class', 'operators'];
$table->setHeaders($headers)->shouldBeCalled()->willReturn($table);
$table->setRows(Argument::any())->shouldBeCalled();
$table->render(Argument::any())->shouldBeCalled();
$this->dump($output, $helperSet);
}
示例7:
function it_dumps_field_filters(OutputInterface $output, HelperSet $helperSet, TableHelper $table, $repository)
{
$output->writeln(Argument::any())->shouldBeCalled();
$repository->findAll()->willReturn([]);
$helperSet->get('table')->willReturn($table);
$headers = ['attribute', 'localizable', 'scopable', 'attribute type', 'filter_class', 'operators'];
$table->setHeaders($headers)->shouldBeCalled()->willReturn($table);
$table->setRows(Argument::any())->shouldBeCalled();
$table->render(Argument::any())->shouldBeCalled();
$this->dump($output, $helperSet);
}
示例8: testIteration
public function testIteration()
{
$helperset = new HelperSet();
$helperset->set($this->getGenericMockHelper('fake_helper_01', $helperset));
$helperset->set($this->getGenericMockHelper('fake_helper_02', $helperset));
$helpers = array('fake_helper_01', 'fake_helper_02');
$i = 0;
foreach ($helperset as $helper) {
$this->assertEquals($helpers[$i++], $helper->getName());
}
}
示例9: createCommand
/**
* @param HelperSet $helpers
* @return TravisCiCommand
* @throws \Symfony\Component\Console\Exception\InvalidArgumentException
* @throws \Symfony\Component\Console\Exception\LogicException
*/
public static function createCommand(HelperSet $helpers)
{
/** @var QuestionHelper $questionHelper */
$questionHelper = $helpers->get('question');
$travisCiQuestionHelper = new TravisCiQuestionHelper($questionHelper);
/** @var PackageHelper $packageHelper */
$packageHelper = $helpers->get('package');
$configBuilder = new ConfigBuilder($travisCiQuestionHelper, $packageHelper);
$configWriter = new ConfigWriter();
return new TravisCiCommand($travisCiQuestionHelper, $configBuilder, $configWriter);
}
示例10: ArrayInput
function it_should_execute_when_calling_fire_action(QuestionHelper $question, HelperSet $helpers)
{
$helpers->get('question')->willReturn($question);
$input = new ArrayInput([]);
$output = new NullOutput();
$query = Argument::type('Symfony\\Component\\Console\\Question\\ChoiceQuestion');
$question->ask($input, $output, $query)->willReturn(1);
$helpers->get('question')->willReturn($question);
$this->setHelperSet($helpers);
$this->run($input, $output);
$this->fire();
}
示例11: createService
/**
* Sets the dojo theme to use.
*
* @param \Zend\ServiceManager\ServiceLocatorInterface $serviceLocator
* @return \Symfony\Component\Console\Application
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$config = $serviceLocator->get('Config')['sds']['dojo'];
$configHelper = new \Sds\DojoModule\Tools\Console\Helper\ConfigHelper($config);
$helperSet = new HelperSet();
$helperSet->set($configHelper, 'config');
$cli = new Application();
$cli->setName('DojoModule Command Line Interface');
$cli->setHelperSet($helperSet);
$cli->addCommands(array(new \Sds\DojoModule\Tools\Console\Command\GenerateProfile()));
return $cli;
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->application = static::getMock(Application::class);
$this->sut = $this->getSut();
$command = static::getMockBuilder(Command::class)->disableOriginalConstructor()->getMock();
$command->expects(static::any())->method('getApplication')->willReturn($this->application);
$command->expects(static::any())->method('getName')->willReturn('mock command');
$helperSet = new HelperSet();
$helperSet->setCommand($command);
$this->sut->setHelperSet($helperSet);
$this->application->setHelperSet($helperSet);
}
示例13: testExecute
public function testExecute()
{
$profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
$profiler->expects($this->once())->method('import')->will($this->returnValue(new Profile('TOKEN')));
$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\\Component\\Console\\Helper\\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');
$command = new ImportCommand($profiler);
$command->setHelperSet($helperSet);
$commandTester = new CommandTester($command);
$commandTester->execute(array('filename' => __DIR__ . '/../Fixtures/profile.data'));
$this->assertRegExp('/Profile "TOKEN" has been successfully imported\\./', $commandTester->getDisplay());
}
示例14: yes
/**
* If the user answers yes then we can override the file
* or if the file doesn't exist then we will just answer
* yes because we aren't overriding anything.
*
* @param string $filename
* @param OutputInterface $output
* @param HelperSet $helperSet
* @return boolean
*/
protected function yes($filename, $output, $helperSet, $options)
{
if (!$this->file->exists($this->basePath . '/' . $filename)) {
return true;
}
if (isset($options['yes']) && $options['yes'] == true) {
return true;
}
$dialog = $helperSet->get('dialog');
if ($dialog->askConfirmation($output, "<question>Would you like to override {$filename}? [y/N]</question>", false)) {
return true;
}
return false;
}
示例15: dump
/**
* {@inheritdoc}
*/
public function dump(OutputInterface $output, HelperSet $helperSet)
{
$output->writeln("<info>Useable attributes filters...</info>");
$attributeFilters = $this->getAttributeFilters();
$attributes = $this->repository->findAll();
$rows = [];
foreach ($attributes as $attribute) {
$rows = array_merge($rows, $this->getFilterInformationForAttribute($attribute, $attributeFilters));
}
$table = $helperSet->get('table');
$headers = ['attribute', 'localizable', 'scopable', 'attribute type', 'operators', 'filter_class'];
$table->setHeaders($headers)->setRows($rows);
$table->render($output);
}