當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。