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


PHP ConsoleCommandEvent::getInput方法代码示例

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


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

示例1: onConsoleCommand

 /**
  * @param ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if ($command instanceof HelpCommand) {
         $command = $this->getCommandFromHelpCommand($command, $event->getInput());
     }
     if (!$command instanceof FormBasedCommand) {
         return;
     }
     $inputDefinition = $this->inputDefinitionFactory->createForFormType($command->formType());
     $this->setInputDefinition($command, $event->getInput(), $inputDefinition);
 }
开发者ID:bangpound,项目名称:symfony-console-form,代码行数:15,代码来源:SetInputDefinitionOfFormBasedCommandEventListener.php

示例2: checkBundleForTranslatingRoutes

 /**
  * This function saves the bundle whose routes shall be translated in a global variable to be used in
  * Zikula\RoutesModule\Translation\DefaultRouteExclusionStrategy later on.
  *
  * @param ConsoleCommandEvent $event
  */
 public function checkBundleForTranslatingRoutes(ConsoleCommandEvent $event)
 {
     if ($event->getCommand()->getName() !== 'translation:extract') {
         return;
     }
     $GLOBALS['translation_extract_routes'] = true;
     if ($event->getInput()->hasParameterOption('--bundle')) {
         $bundle = $event->getInput()->getParameterOption('--bundle');
         if ('@' === $bundle[0]) {
             $bundle = substr($bundle, 1);
         }
         $GLOBALS['translation_extract_routes_bundle'] = $bundle;
     }
 }
开发者ID:Silwereth,项目名称:core,代码行数:20,代码来源:ConsoleCommandListener.php

示例3: setGlobalOptions

 /**
  * Before a Console command runs, examine the global
  * commandline options from the event Input, and set
  * configuration values as appropriate.
  *
  * @param ConsoleCommandEvent $event
  */
 public function setGlobalOptions(ConsoleCommandEvent $event)
 {
     /* @var Input $input */
     $input = $event->getInput();
     // TODO: We need a good strategy for managing global options.
     // $simulate = $input->getOption('simulate');
 }
开发者ID:jibran,项目名称:drush,代码行数:14,代码来源:GlobalOptionsEventListener.php

示例4: onConsoleCommand

 /**
  * @param ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     $input = $event->getInput();
     if (in_array($command->getName(), $this->ignoredCommands)) {
         $this->interactor->ignoreTransaction();
     }
     if ($this->newRelic->getName()) {
         $this->interactor->setApplicationName($this->newRelic->getName(), $this->newRelic->getLicenseKey(), $this->newRelic->getXmit());
     }
     $this->interactor->setTransactionName($command->getName());
     $this->interactor->enableBackgroundJob();
     // send parameters to New Relic
     foreach ($input->getOptions() as $key => $value) {
         $key = '--' . $key;
         if (is_array($value)) {
             foreach ($value as $k => $v) {
                 $this->interactor->addCustomParameter($key . '[' . $k . ']', $v);
             }
         } else {
             $this->interactor->addCustomParameter($key, $value);
         }
     }
     foreach ($input->getArguments() as $key => $value) {
         if (is_array($value)) {
             foreach ($value as $k => $v) {
                 $this->interactor->addCustomParameter($key . '[' . $k . ']', $v);
             }
         } else {
             $this->interactor->addCustomParameter($key, $value);
         }
     }
 }
开发者ID:Aerendir,项目名称:EkinoNewRelicBundle,代码行数:36,代码来源:CommandListener.php

示例5: onCronStart

 /**
  * @param ConsoleCommandEvent $event
  */
 public function onCronStart(ConsoleCommandEvent $event)
 {
     if (!$this->isCronCommand($event->getCommand()->getName(), $event->getInput())) {
         $this->skipped = true;
         return;
     }
     $this->start = microtime(true);
 }
开发者ID:Baby-Markt,项目名称:CronBundle,代码行数:11,代码来源:ExecutionReportListener.php

示例6: onConsoleCommand

 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $this->siteAccess->name = $event->getInput()->getParameterOption('--siteaccess', $this->defaultSiteAccessName);
     $this->siteAccess->matchingType = 'cli';
     if (!in_array($this->siteAccess->name, $this->siteAccessList)) {
         throw new InvalidSiteAccessException($this->siteAccess->name, $this->siteAccessList, $this->siteAccess->matchingType);
     }
     $this->eventDispatcher->dispatch(MVCEvents::CONFIG_SCOPE_CHANGE, new ScopeChangeEvent($this->siteAccess));
 }
开发者ID:Pixy,项目名称:ezpublish-kernel,代码行数:9,代码来源:ConsoleCommandListener.php

示例7: onConsoleCommand

 /**
  * @param ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     $input = $event->getInput();
     $this->addOptionsToCommand($command, $input);
     $listeners = $this->getListenersToDisable($input);
     if (!empty($listeners)) {
         $this->listenersManager->disableListeners($listeners);
     }
 }
开发者ID:Maksold,项目名称:platform,代码行数:13,代码来源:OptionalListenersListener.php

示例8: initializeEventIo

 /**
  * @see getSubscribedEvents
  *
  * @param ConsoleCommandEvent $event
  */
 public function initializeEventIo(ConsoleCommandEvent $event)
 {
     $set = $event->getCommand()->getHelperSet();
     if (!$set->has(self::HELPER_NAME)) {
         return;
     }
     /** @var  $helper IoHelper */
     $helper = $set->get(self::HELPER_NAME);
     $helper->initializeIo($event->getInput(), $event->getOutput());
 }
开发者ID:netz98,项目名称:n98-magerun,代码行数:15,代码来源:IoHelper.php

示例9: onConsoleCommand

 /**
  * @param ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if (!$command instanceof FormBasedCommand) {
         return;
     }
     $input = $event->getInput();
     $output = $event->getOutput();
     $formData = $this->formQuestionHelper->interactUsingForm($command->formType(), $input, $output);
     $command->setFormData($formData);
 }
开发者ID:bangpound,项目名称:symfony-console-form,代码行数:14,代码来源:HandleFormBasedCommandEventListener.php

示例10: initialize

 public function initialize(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if (!$command instanceof TableFeature) {
         return;
     }
     $input = $event->getInput();
     $layout = $input->getOption('table-layout');
     if ($layout && !in_array($layout, $this->validLayouts, true)) {
         throw new \InvalidArgumentException(sprintf('The table-layout option must be passed one of "%s" but was given "%s"', implode(', ', $this->validLayouts), $layout));
     }
 }
开发者ID:mistymagich,项目名称:gush,代码行数:12,代码来源:TableSubscriber.php

示例11: alterCommandOptions

 /**
  * @param ConsoleCommandEvent $event
  */
 public function alterCommandOptions(ConsoleCommandEvent $event)
 {
     /* @var Command $command */
     $command = $event->getCommand();
     $input = $event->getInput();
     if ($command->getName() == 'help') {
         // Symfony 3.x prepares $input for us; Symfony 2.x, on the other
         // hand, passes it in prior to binding with the command definition,
         // so we have to go to a little extra work.  It may be inadvisable
         // to do these steps for commands other than 'help'.
         if (!$input->hasArgument('command_name')) {
             $command->ignoreValidationErrors();
             $command->mergeApplicationDefinition();
             $input->bind($command->getDefinition());
         }
         $nameOfCommandToDescribe = $event->getInput()->getArgument('command_name');
         $commandToDescribe = $this->application->find($nameOfCommandToDescribe);
         $this->findAndAddHookOptions($commandToDescribe);
     } else {
         $this->findAndAddHookOptions($command);
     }
 }
开发者ID:consolidation,项目名称:annotated-command,代码行数:25,代码来源:AlterOptionsCommandEvent.php

示例12: setGlobalOptions

 /**
  * Before a Console command runs, examine the global
  * commandline options from the event Input, and set
  * configuration values as appropriate.
  *
  * @param \Symfony\Component\Console\Event\ConsoleCommandEvent $event
  */
 public function setGlobalOptions(ConsoleCommandEvent $event)
 {
     $config = $this->getConfig();
     $input = $event->getInput();
     $globalOptions = $config->getGlobalOptionDefaultValues();
     foreach ($globalOptions as $option => $default) {
         $value = $input->hasOption($option) ? $input->getOption($option) : null;
         // Unfortunately, the `?:` operator does not differentate between `0` and `null`
         if (!isset($value)) {
             $value = $default;
         }
         $config->set($option, $value);
     }
 }
开发者ID:jjok,项目名称:Robo,代码行数:21,代码来源:GlobalOptionsEventListener.php

示例13: initialize

 public function initialize(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if ($command instanceof TemplateFeature) {
         $input = $event->getInput();
         $template = $input->getOption('template');
         if ($template) {
             $validTemplates = $this->templateHelper->getNamesForDomain($command->getTemplateDomain());
             if (!in_array($template, $validTemplates, true)) {
                 throw new \InvalidArgumentException(sprintf('The specified template "%s" does not exist, try one of: ' . PHP_EOL . ' - %s', $template, implode(PHP_EOL . ' - ', $validTemplates)));
             }
         }
     }
 }
开发者ID:mistymagich,项目名称:gush,代码行数:14,代码来源:TemplateSubscriber.php

示例14: showMessage

 /**
  * @param ConsoleCommandEvent $event
  */
 public function showMessage(ConsoleCommandEvent $event)
 {
     /**
      * @var \Drupal\Console\Command\Command $command
      */
     $command = $event->getCommand();
     $input = $event->getInput();
     $output = $event->getOutput();
     $output = new DrupalStyle($input, $output);
     $application = $command->getApplication();
     $translatorHelper = $application->getTranslator();
     $welcomeMessageKey = 'commands.' . str_replace(':', '.', $command->getName()) . '.welcome';
     $welcomeMessage = $translatorHelper->trans($welcomeMessageKey);
     if ($welcomeMessage != $welcomeMessageKey) {
         $output->text($welcomeMessage);
     }
 }
开发者ID:desarrollolibre,项目名称:DrupalConsole,代码行数:20,代码来源:ShowWelcomeMessageListener.php

示例15: onCommand

 public function onCommand(ConsoleCommandEvent $event)
 {
     /** @var PathHelper $path */
     $path = $event->getCommand()->getHelper('path');
     $this->old_working_dir = getcwd();
     $working_dir = $event->getInput()->getOption('project-path');
     $real_working_dir = realpath($working_dir);
     if (!$real_working_dir) {
         $event->getOutput()->writeln(sprintf('The specified project-path "%s" does not exist.', $working_dir));
         $event->stopPropagation();
         $event->disableCommand();
         return;
     }
     $path->setProjectPath($working_dir);
     $event->getOutput()->writeln(sprintf("Changing directory to %s", $working_dir));
     chdir($real_working_dir);
 }
开发者ID:quickstrap,项目名称:quickstrap,代码行数:17,代码来源:CwdSubscriber.php


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