当前位置: 首页>>代码示例>>PHP>>正文


PHP InputInterface::bind方法代码示例

本文整理汇总了PHP中Symfony\Component\Console\Input\InputInterface::bind方法的典型用法代码示例。如果您正苦于以下问题:PHP InputInterface::bind方法的具体用法?PHP InputInterface::bind怎么用?PHP InputInterface::bind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Component\Console\Input\InputInterface的用法示例。


在下文中一共展示了InputInterface::bind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: addOptionsToCommand

 /**
  * @param Command $command
  * @param InputInterface $input
  */
 protected function addOptionsToCommand(Command $command, InputInterface $input)
 {
     $inputDefinition = $command->getApplication()->getDefinition();
     $inputDefinition->addOption(new InputOption(self::DISABLE_OPTIONAL_LISTENERS, null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, sprintf('Disable optional listeners, "%s" to disable all listeners, ' . 'command "%s" shows all listeners', self::ALL_OPTIONAL_LISTENERS_VALUE, OptionalListenersCommand::NAME)));
     $command->mergeApplicationDefinition();
     $input->bind($command->getDefinition());
 }
开发者ID:Maksold,项目名称:platform,代码行数:11,代码来源:OptionalListenersListener.php

示例2: doRun

 /**
  * Implements symfony/console doRun launching method
  * @param InputInterface  $input  Underlying symfony/console InputInterface
  * @param OutputInterface $output Underlying symfony/console OutputInterface
  */
 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $this->input = $input;
     $this->output = $output;
     // Binding input definition
     $this->input->bind(new \SCQAT\CLI\Definition());
     // Determining analyzed directory
     $analyzedDirectory = "";
     $optionDirectory = $this->input->getOption("directory");
     if (!empty($optionDirectory)) {
         $analyzedDirectory = rtrim($this->input->getOption("directory"), "/") . "/";
     }
     $this->analyzedDirectory = realpath($analyzedDirectory) . DIRECTORY_SEPARATOR;
     // Creating SCQAT Context
     $context = new \SCQAT\Context($this->vendorDirectory, $this->analyzedDirectory);
     // Attach CLI specific report hooks to the context if configuration allows it
     if (in_array("console", $context->configuration["Reports"])) {
         $context->attachReportHooks(new \SCQAT\CLI\ReportHooks($this->output, $this->input->getOption("verbose")));
     }
     // Gathering files to analyze
     $files = $this->gatherFiles($context);
     if (count($files)) {
         // Attach gathered files to the context
         $context->files = $files;
         // Run SCQAT runner on the context
         $this->runner->run($context);
     }
     // Exit CLI application on error if any were found
     if ($context->hadError !== false) {
         return 1;
     }
 }
开发者ID:clorichel,项目名称:SCQAT,代码行数:37,代码来源:CLI.php

示例3:

 function it_updates_a_avaivalble_exchange_rate(ContainerInterface $container, InputInterface $input, OutputInterface $output, ImporterInterface $importer, CurrencyInterface $currency)
 {
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled();
     $input->validate()->shouldBeCalled();
     $output->writeln('Fetching data from external database.')->shouldBeCalled();
     $input->getArgument('importer')->shouldBeCalled()->willreturn('importer');
     $container->get('sylius.currency_importer.importer')->shouldBeCalled()->willreturn($importer);
     $importer->import()->shouldBeCalled();
     $output->writeln('Saving updated exchange rates.')->shouldBeCalled();
     $this->setContainer($container);
     $this->run($input, $output);
 }
开发者ID:nanyi,项目名称:Sylius,代码行数:13,代码来源:ImportExchangeRateCommandSpec.php

示例4:

 function it_executes(InputInterface $input, OutputInterface $output, UserCommandBus $commandBus)
 {
     $input->getArgument('email')->shouldBeCalled()->willReturn('user@user.com');
     $input->getArgument('password')->shouldBeCalled()->willReturn(123456);
     $input->hasArgument('command')->shouldBeCalled()->willReturn(true);
     $input->getArgument('command')->shouldBeCalled()->willReturn('command');
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled()->willReturn(true);
     $input->validate()->shouldBeCalled();
     $commandBus->handle(Argument::type(WithoutOldPasswordChangeUserPasswordCommand::class))->shouldBeCalled()->willReturn(['email' => 'user@user.com', 'password' => 123456]);
     $output->writeln(sprintf('Changed password of <comment>%s</comment> %s', 'user@user.com', 'user'))->shouldBeCalled();
     $this->run($input, $output);
 }
开发者ID:BenGorUser,项目名称:UserBundle,代码行数:13,代码来源:ChangePasswordCommandSpec.php

示例5: loadCommands

 /**
  * @param InputInterface $input
  * @param OutputInterface $output
  * @throws \Exception
  */
 public function loadCommands(InputInterface $input, OutputInterface $output)
 {
     // $application is required to be defined in the register_command scripts
     $application = $this->application;
     $inputDefinition = $application->getDefinition();
     $inputDefinition->addOption(new InputOption('no-warnings', null, InputOption::VALUE_NONE, 'Skip global warnings, show command output only', null));
     try {
         $input->bind($inputDefinition);
     } catch (\RuntimeException $e) {
         //expected if there are extra options
     }
     if ($input->getOption('no-warnings')) {
         $output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
     }
     require_once __DIR__ . '/../../../core/register_command.php';
     if ($this->config->getSystemValue('installed', false)) {
         if (\OCP\Util::needUpgrade()) {
             $output->writeln("ownCloud or one of the apps require upgrade - only a limited number of commands are available");
             $output->writeln("You may use your browser or the occ upgrade command to do the upgrade");
         } elseif ($this->config->getSystemValue('maintenance', false)) {
             $output->writeln("ownCloud is in maintenance mode - no app have been loaded");
         } else {
             OC_App::loadApps();
             foreach (\OC::$server->getAppManager()->getInstalledApps() as $app) {
                 $appPath = \OC_App::getAppPath($app);
                 if ($appPath === false) {
                     continue;
                 }
                 \OC::$loader->addValidRoot($appPath);
                 $file = $appPath . '/appinfo/register_command.php';
                 if (file_exists($file)) {
                     require $file;
                 }
             }
         }
     } else {
         $output->writeln("ownCloud is not installed - only a limited number of commands are available");
     }
     $input = new ArgvInput();
     if ($input->getFirstArgument() !== 'check') {
         $errors = \OC_Util::checkServer(\OC::$server->getConfig());
         if (!empty($errors)) {
             foreach ($errors as $error) {
                 $output->writeln((string) $error['error']);
                 $output->writeln((string) $error['hint']);
                 $output->writeln('');
             }
             throw new \Exception("Environment not properly prepared.");
         }
     }
 }
开发者ID:stweil,项目名称:owncloud-core,代码行数:56,代码来源:Application.php

示例6:

 function it_executes(InputInterface $input, OutputInterface $output, UserCommandBus $commandBus)
 {
     $input->getArgument('email')->shouldBeCalled()->willReturn('user@user.com');
     $input->getArgument('password')->shouldBeCalled()->willReturn(123456);
     $input->getArgument('roles')->shouldBeCalled()->willReturn(['ROLE_USER', 'ROLE_ADMIN']);
     $input->hasArgument('command')->shouldBeCalled()->willReturn(true);
     $input->getArgument('command')->shouldBeCalled()->willReturn('command');
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled()->willReturn(true);
     $input->validate()->shouldBeCalled();
     $commandBus->handle(Argument::type(SignUpUserCommand::class))->shouldBeCalled();
     $output->writeln(sprintf('Created %s: <comment>%s</comment>', 'user', 'user@user.com'))->shouldBeCalled();
     $this->run($input, $output);
 }
开发者ID:BenGorUser,项目名称:UserBundle,代码行数:14,代码来源:CreateUserCommandSpec.php

示例7: testShouldPropagateCustomOptionsIntoProcess

 public function testShouldPropagateCustomOptionsIntoProcess()
 {
     $this->input = new StringInput('trolling chrome' . ' --' . RunTestsCommand::OPTION_SERVER_URL . '=http://foo.bar:1337' . ' --' . RunTestsCommand::OPTION_FIXTURES_DIR . '=custom-fixtures-dir/' . ' --' . RunTestsCommand::OPTION_LOGS_DIR . '=custom-logs-dir/' . ' --' . RunTestsCommand::OPTION_PUBLISH_RESULTS);
     $this->input->bind($this->command->getDefinition());
     // Redeclare creator so it uses the new input
     $this->creator = new ProcessSetCreator($this->command, $this->input, $this->bufferedOutput, $this->publisherMock);
     $files = $this->findDummyTests('DummyTest.php');
     // find only one file (we don't need more for the test)
     $processSet = $this->creator->createFromFiles($files, [], []);
     /** @var Process $process */
     $process = $processSet->get(ProcessSet::PROCESS_STATUS_QUEUED)[self::NAME_DUMMY_TEST]->process;
     $processEnv = $process->getEnv();
     $this->assertArraySubset(['BROWSER_NAME' => 'chrome', 'ENV' => 'trolling', 'SERVER_URL' => 'http://foo.bar:1337', 'PUBLISH_RESULTS' => '1', 'FIXTURES_DIR' => 'custom-fixtures-dir/', 'LOGS_DIR' => 'custom-logs-dir/'], $processEnv);
 }
开发者ID:jirinovak,项目名称:steward,代码行数:14,代码来源:ProcessSetCreatorTest.php

示例8: doRun

 public function doRun(InputInterface $input, OutputInterface $output)
 {
     $input->bind($this->getDefinition());
     $options = $input->getOptions();
     $this->setConfigurationOverride($options['config']);
     $this->setCatchExceptions(true);
     $imageFinder = new Image\Finder($this);
     $image = Image\Image::createFromConfig($this->getConfiguration());
     $this->get('install:assets')->inject($imageFinder);
     $this->get('refresh:thumbnails')->inject($image, $imageFinder);
     $this->get('refresh:covers')->inject($image, $imageFinder);
     $this->get('refresh:json')->inject($imageFinder);
     return parent::doRun($input, $output);
 }
开发者ID:hoborglabs,项目名称:sgallery,代码行数:14,代码来源:Application.php

示例9:

 function it_can_output_a_message(HelloService $helloService, InputInterface $input, OutputInterface $output)
 {
     //ARRANGE
     // Some shit the Symfony Console component needs to be testable
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive(Argument::any())->shouldBeCalled();
     $input->validate(Argument::any())->shouldBeCalled();
     // Prep the service
     $helloService->getGreeting(Argument::type('\\CodeKata\\RomanNumerals\\Domain\\Name'))->willReturn('Hello, Sam');
     // Give the command an input
     $input->getArgument('name')->willReturn('Sam');
     // ASSERT
     $output->writeln('Hello, Sam')->shouldBeCalled();
     // ACT
     $this->run($input, $output);
 }
开发者ID:scottbeaman,项目名称:codekata,代码行数:16,代码来源:HelloCommandSpec.php

示例10:

 function it_updates_all_exchange_rate(ContainerInterface $container, InputInterface $input, OutputInterface $output, EntityRepository $repository, ImporterInterface $importer, CurrencyInterface $currency)
 {
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled();
     $input->validate()->shouldBeCalled();
     $output->writeln('Fetching data from external database.')->shouldBeCalled();
     $input->hasOption('all')->shouldBeCalled()->willreturn(true);
     $container->get('sylius.repository.currency')->shouldBeCalled()->willreturn($repository);
     $repository->findAll()->shouldBeCalled()->willreturn(array($currency));
     $input->getArgument('importer')->shouldBeCalled()->willreturn('importer');
     $container->get('sylius.currency_importer.importer')->shouldBeCalled()->willreturn($importer);
     $importer->import(array($currency))->shouldBeCalled();
     $output->writeln('Saving updated exchange rates.')->shouldBeCalled();
     $this->setContainer($container);
     $this->run($input, $output);
 }
开发者ID:nanyi,项目名称:Sylius,代码行数:16,代码来源:UpdateExchangeRateCommandSpec.php

示例11: it_create_client

 public function it_create_client(ContainerInterface $container, InputInterface $input, OutputInterface $output, ClientManager $clientManager, Client $client)
 {
     $container->get('fos_oauth_server.client_manager.default')->willReturn($clientManager);
     $clientManager->createClient()->willReturn($client);
     $input->getOption('redirect-uri')->willReturn(array('redirect-uri'));
     $input->getOption('grant-type')->willReturn(array('grant-type'));
     $client->setRedirectUris(array('redirect-uri'))->shouldBeCalled();
     $client->setAllowedGrantTypes(array('grant-type'))->shouldBeCalled();
     $clientManager->updateClient($client)->shouldBeCalled();
     $client->getPublicId()->shouldBeCalled();
     $client->getSecret()->shouldBeCalled();
     $output->writeln(Argument::type('string'))->shouldBeCalled();
     $this->setContainer($container);
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled();
     $input->validate()->shouldBeCalled();
     $this->run($input, $output);
 }
开发者ID:Strontium-90,项目名称:Sylius,代码行数:18,代码来源:CreateClientCommandSpec.php

示例12:

 function it_executes(ContainerInterface $container, ClientManager $clientManager, ClientInterface $client, InputInterface $input, OutputInterface $output)
 {
     $container->get('fos_oauth_server.client_manager.default')->shouldBeCalled()->willReturn($clientManager);
     $clientManager->createClient()->shouldBeCalled()->willReturn($client);
     $input->hasArgument('command')->shouldBeCalled()->willReturn(true);
     $input->getArgument('command')->shouldBeCalled()->willReturn('command');
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled()->willReturn(false);
     $input->validate()->shouldBeCalled();
     $input->getOption('redirect-uri')->shouldBeCalled()->willReturn(['the-redirect-uri']);
     $client->setRedirectUris(['the-redirect-uri'])->shouldBeCalled();
     $input->getOption('grant-type')->shouldBeCalled()->willReturn(['the-grant-type']);
     $client->setAllowedGrantTypes(['the-grant-type'])->shouldBeCalled();
     $clientManager->updateClient($client)->shouldBeCalled();
     $client->getPublicId()->shouldBeCalled()->willReturn('public-id');
     $client->getSecret()->shouldBeCalled()->willReturn('secret');
     $output->writeln(sprintf('A new client with public id <info>%s</info>, secret <info>%s</info> has been added', 'public-id', 'secret'))->shouldBeCalled();
     $this->run($input, $output);
 }
开发者ID:dasklney,项目名称:kreta,代码行数:19,代码来源:CreateClientCommandSpec.php

示例13:

 function it_executes(ContainerInterface $container, UserFactory $userFactory, UserInterface $user, UserManager $userManager, InputInterface $input, OutputInterface $output)
 {
     $container->get('kreta_user.factory.user')->shouldBeCalled()->willReturn($userFactory);
     $input->bind(Argument::any())->shouldBeCalled();
     $input->isInteractive()->shouldBeCalled()->willReturn(true);
     $input->validate()->shouldBeCalled();
     $input->hasArgument('command')->shouldBeCalled()->willReturn(true);
     $input->getArgument('command')->shouldBeCalled()->willReturn('command');
     $input->getArgument('email')->shouldBeCalled()->willReturn('kreta@kreta.com');
     $input->getArgument('username')->shouldBeCalled()->willReturn('kreta');
     $input->getArgument('firstName')->shouldBeCalled()->willReturn('Kreta');
     $input->getArgument('lastName')->shouldBeCalled()->willReturn('User');
     $input->getArgument('password')->shouldBeCalled()->willReturn('123456');
     $userFactory->create('kreta@kreta.com', 'kreta', 'Kreta', 'User', true)->shouldBeCalled()->willReturn($user);
     $user->setPlainPassword('123456')->shouldBeCalled()->willReturn($user);
     $container->get('fos_user.user_manager')->shouldBeCalled()->willReturn($userManager);
     $userManager->updatePassword($user)->shouldBeCalled();
     $userManager->updateUser($user)->shouldBeCalled()->willReturn($user);
     $user->getUsername()->shouldBeCalled()->willReturn('kreta');
     $output->writeln(sprintf('A new <info>%s</info> user has been created', 'kreta'))->shouldBeCalled();
     $this->run($input, $output);
 }
开发者ID:cespedosa,项目名称:kreta,代码行数:22,代码来源:CreateUserCommandSpec.php

示例14: run

 /**
  * Runs the command.
  *
  * The code to execute is either defined directly with the
  * setCode() method or by overriding the execute() method
  * in a sub-class.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  *
  * @throws \Exception
  *
  * @see setCode()
  * @see execute()
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     // force the creation of the synopsis before the merge with the app definition
     $this->getSynopsis(true);
     $this->getSynopsis(false);
     // add the application arguments and options
     $this->mergeApplicationDefinition();
     // bind the input against the command specific arguments/options
     try {
         $input->bind($this->definition);
     } catch (ExceptionInterface $e) {
         if (!$this->ignoreValidationErrors) {
             throw $e;
         }
     }
     $this->initialize($input, $output);
     if (null !== $this->processTitle) {
         if (function_exists('cli_set_process_title')) {
             cli_set_process_title($this->processTitle);
         } elseif (function_exists('setproctitle')) {
             setproctitle($this->processTitle);
         } elseif (OutputInterface::VERBOSITY_VERY_VERBOSE === $output->getVerbosity()) {
             $output->writeln('<comment>Install the proctitle PECL to be able to change the process title.</comment>');
         }
     }
     if ($input->isInteractive()) {
         $this->interact($input, $output);
     }
     // The command name argument is often omitted when a command is executed directly with its run() method.
     // It would fail the validation if we didn't make sure the command argument is present,
     // since it's required by the application.
     if ($input->hasArgument('command') && null === $input->getArgument('command')) {
         $input->setArgument('command', $this->getName());
     }
     $input->validate();
     if ($this->code) {
         $statusCode = call_user_func($this->code, $input, $output);
     } else {
         $statusCode = $this->execute($input, $output);
     }
     return is_numeric($statusCode) ? (int) $statusCode : 0;
 }
开发者ID:Kyra2778,项目名称:AMR,代码行数:59,代码来源:Command.php

示例15: run

 /**
  * Runs the command.
  *
  * Before the decorated command is run, a lock is requested.
  * When failed to acquire the lock, the command exits.
  *
  * @param InputInterface  $input  An InputInterface instance
  * @param OutputInterface $output An OutputInterface instance
  *
  * @return int The command exit code
  */
 public function run(InputInterface $input, OutputInterface $output)
 {
     $this->mergeApplicationDefinition();
     $input->bind($this->getDefinition());
     $lock = $this->getLockHandler($input);
     if (!$lock->lock()) {
         $this->writeLockedMessage($input, $output);
         return 1;
     }
     try {
         return $this->decoratedCommand->run($input, $output);
     } finally {
         $lock->release();
     }
 }
开发者ID:frankdejonge,项目名称:locked-console-command,代码行数:26,代码来源:LockedCommandDecorator.php


注:本文中的Symfony\Component\Console\Input\InputInterface::bind方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。