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