本文整理汇总了PHP中Symfony\Component\Console\Helper\HelperSet::set方法的典型用法代码示例。如果您正苦于以下问题:PHP HelperSet::set方法的具体用法?PHP HelperSet::set怎么用?PHP HelperSet::set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Console\Helper\HelperSet
的用法示例。
在下文中一共展示了HelperSet::set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
示例2: 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;
}
示例3: setUp
protected function setUp()
{
parent::setUp();
$this->inputMock = static::getMock(InputInterface::class);
$this->outputMock = static::getMock(OutputInterface::class);
$this->packageMock = static::getMock(PackageHelper::class);
$this->requireMock = static::getMock(RequireHelper::class);
$this->questionMock = Mockery::mock(QuestionHelper::class)->makePartial();
$helperSet = new HelperSet();
$helperSet->set($this->questionMock, 'question');
$helperSet->set($this->packageMock, 'package');
$helperSet->set($this->requireMock, 'composer require');
$this->sut = new CodeSnifferCommand();
$this->sut->setHelperSet($helperSet);
}
示例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->getOption('dump-sql')) {
$arguments['--dump-sql'] = $input->getOption('dump-sql');
}
$command = new CreateCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
示例5: mockQuestionHelper
/**
* Mocks question helper.
*/
protected function mockQuestionHelper(array $answers)
{
foreach ($answers as $key => $answer) {
$this->questionHelper->expects($this->at($key + 2))->method('ask')->will($this->returnValue($answer));
}
$this->helperSet->set($this->questionHelper, 'question');
}
示例6: 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);
}
}
示例7: 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->getOption('editor-cmd')) {
$arguments['--editor-cmd'] = $input->getOption('editor-cmd');
}
$configDir = $this->get('config')->get('[directories][config_dir]');
$arguments['--configuration'] = $configDir . '/migrations.yml';
$command = new GenerateCommand();
$command->setHelperSet($helperSet);
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
示例8: setUp
protected function setUp()
{
parent::setUp();
$this->inputMock = static::getMock(InputInterface::class);
$this->outputMock = static::getMock(OutputInterface::class);
$this->packageMock = static::getMock(PackageHelper::class);
$this->requireMock = static::getMock(RequireHelper::class);
$this->questionMock = Mockery::mock(QuestionHelper::class)->makePartial();
$this->processMock = static::getMockBuilder(Process::class)->disableOriginalConstructor()->getMock();
$this->factoryMock = static::getMockBuilder(ProcessFactory::class)->disableProxyingToOriginalMethods()->getMock();
$this->factoryMock->expects(static::any())->method('create')->willReturn($this->processMock);
$helperSet = new HelperSet();
$helperSet->set($this->questionMock, 'question');
$helperSet->set($this->packageMock, 'package');
$helperSet->set($this->requireMock, 'composer require');
$this->sut = new BehatCommand($this->factoryMock);
$this->sut->setHelperSet($helperSet);
}
示例9: 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');
$command = new GenerateProxiesCommand();
$command->setHelperSet($helperSet);
$arguments = array();
if ($input->getOption('filter')) {
$arguments['--filter'] = $input->getOption('filter');
}
if ($input->getArgument('dest-path')) {
$arguments['dest-path'] = $input->getArgument('dest-path');
}
$returnCode = $command->run(new ArrayInput($arguments), $output);
return $returnCode;
}
示例10: 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);
}
示例11: 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());
}
}
示例12: setUp
protected function setUp()
{
parent::setUp();
$this->inputMock = static::getMock(InputInterface::class);
$this->outputMock = static::getMock(OutputInterface::class);
$this->packageMock = static::getMock(PackageHelper::class);
$this->requireMock = static::getMock(RequireHelper::class);
$this->pathMock = static::getMock(PathHelper::class);
$this->questionMock = Mockery::mock(QuestionHelper::class)->makePartial();
$root = vfsStream::setup('projectDir');
$this->configPath = $root->url() . '/phpunit.xml.dist';
$this->pathMock->expects(static::any())->method('getPath')->with('phpunit.xml.dist')->willReturn($this->configPath);
$this->factoryMock = static::getMockBuilder(ConfigurationFactory::class)->disableProxyingToOriginalMethods()->getMock();
$helperSet = new HelperSet();
$helperSet->set($this->questionMock, 'question');
$helperSet->set($this->packageMock, 'package');
$helperSet->set($this->requireMock, 'composer require');
$helperSet->set($this->pathMock, 'path');
$this->sut = new PhpUnitCommand($this->factoryMock);
$this->sut->setHelperSet($helperSet);
}
示例13: 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;
}
示例14: 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());
}
示例15: testExecuteWithToken
public function testExecuteWithToken()
{
$profiler = $this->getMockBuilder('Symfony\\Component\\HttpKernel\\Profiler\\Profiler')->disableOriginalConstructor()->getMock();
$profile = new Profile('TOKEN');
$profiler->expects($this->once())->method('loadProfile')->with('TOKEN')->will($this->returnValue($profile));
$helperSet = new HelperSet();
$helper = $this->getMock('Symfony\\Component\\Console\\Helper\\FormatterHelper');
$helper->expects($this->any())->method('formatSection');
$helperSet->set($helper, 'formatter');
$command = new ExportCommand($profiler);
$command->setHelperSet($helperSet);
$commandTester = new CommandTester($command);
$commandTester->execute(array('token' => 'TOKEN'));
$this->assertEquals($profiler->export($profile), $commandTester->getDisplay());
}