當前位置: 首頁>>代碼示例>>PHP>>正文


PHP ConsoleCommandEvent::getOutput方法代碼示例

本文整理匯總了PHP中Symfony\Component\Console\Event\ConsoleCommandEvent::getOutput方法的典型用法代碼示例。如果您正苦於以下問題:PHP ConsoleCommandEvent::getOutput方法的具體用法?PHP ConsoleCommandEvent::getOutput怎麽用?PHP ConsoleCommandEvent::getOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Symfony\Component\Console\Event\ConsoleCommandEvent的用法示例。


在下文中一共展示了ConsoleCommandEvent::getOutput方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: listenForServerRunCommand

 public function listenForServerRunCommand(ConsoleCommandEvent $event)
 {
     if (!$event->getCommand() instanceof ServerRunCommand) {
         return;
     }
     $argv = $_SERVER['argv'];
     if (count($argv) < 3) {
         return;
     }
     // strip the application name
     array_shift($argv);
     // strip the command name
     array_shift($argv);
     $address = $argv[0];
     if (0 !== strpos($address, '0.0.0.0')) {
         return;
     }
     $address = str_replace('0.0.0.0', $this->getLocalIp(), $address);
     $output = $event->getOutput();
     $output->writeln(sprintf('If you are in a container you would probably prefer to use: <info>http://%s</info>', $address));
     if (function_exists('uprofiler_enable')) {
         $output->writeln(sprintf('XHProf UI: <info>http://%s/xhprof</info>', $address));
     }
     $output->writeln('');
 }
開發者ID:blackfireio,項目名稱:blackfire-workshop,代碼行數:25,代碼來源:ServerRunListener.php

示例2: showGenerateDoc

 /**
  * @param ConsoleCommandEvent $event
  * @return void
  */
 public function showGenerateDoc(ConsoleCommandEvent $event)
 {
     /**
      * @var \Drupal\Console\Command\Command $command
      */
     $command = $event->getCommand();
     /**
      * @var \Drupal\Console\Console\Application $command
      */
     $application = $command->getApplication();
     /**
      * @var \Drupal\Console\Config $config
      */
     $config = $application->getConfig();
     $input = $command->getDefinition();
     $options = $input->getOptions();
     $arguments = $input->getArguments();
     if (isset($options['generate-doc']) && $options['generate-doc'] == 1) {
         foreach ($this->skipOptions as $remove_option) {
             unset($options[$remove_option]);
         }
         $parameters = ['options' => $options, 'arguments' => $arguments, 'command' => $command->getName(), 'description' => $command->getDescription(), 'aliases' => $command->getAliases()];
         $renderedDoc = $application->getHelperSet()->get('renderer')->render('gitbook/generate-doc.md.twig', $parameters);
         $output = $event->getOutput();
         $output->writeln($renderedDoc);
         $event->disableCommand();
     }
 }
開發者ID:janstoeckler,項目名稱:DrupalConsole,代碼行數:32,代碼來源:ShowGenerateDocListener.php

示例3: validateDependencies

 /**
  * @param ConsoleCommandEvent $event
  */
 public function validateDependencies(ConsoleCommandEvent $event)
 {
     /**
      * @var \Drupal\AppConsole\Command\Command $command
      */
     $command = $event->getCommand();
     $output = $event->getOutput();
     $application = $command->getApplication();
     $messageHelper = $application->getHelperSet()->get('message');
     /**
      * @var TranslatorHelper
      */
     $translatorHelper = $application->getHelperSet()->get('translator');
     if (!$command instanceof Command) {
         return;
     }
     $dependencies = $command->getDependencies();
     if ($dependencies) {
         foreach ($dependencies as $dependency) {
             if (\Drupal::moduleHandler()->moduleExists($dependency) === false) {
                 $errorMessage = sprintf($translatorHelper->trans('commands.common.errors.module-dependency'), $dependency);
                 $messageHelper->showMessage($output, $errorMessage, 'error');
                 $event->disableCommand();
             }
         }
     }
 }
開發者ID:nateswart,項目名稱:DrupalConsole,代碼行數:30,代碼來源:ValidateDependenciesListener.php

示例4: setOutputWriter

 public function setOutputWriter(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if (!$this->isMigrationCommand($command)) {
         return;
     }
     $this->outputWriter->setConsoleOutput($event->getOutput());
 }
開發者ID:DIPcom,項目名稱:Sandmin,代碼行數:8,代碼來源:SetConsoleOutputEventSubscriber.php

示例5: onConsoleCommand

 /**
  * @param ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     if ($this->registry->isChainedCommand($command)) {
         $event->disableCommand();
         $event->getOutput()->writeln('<error>Chained command should not be executed directly</error>');
     }
 }
開發者ID:sergeyz,項目名稱:cc,代碼行數:11,代碼來源:ChainCommandListener.php

示例6: 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

示例7: 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

示例8: 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

示例9: onCommand

 /**
  * On Command Event Handler
  *
  * Check if the current command requires EE bootstrapping
  * and throw an exception if EE is not bootstrapped
  *
  * @param  ConsoleCommandEvent $event
  * @return void
  */
 public function onCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     $output = $event->getOutput();
     if (!$this->isCommandExemptFromBootstrap($command)) {
         if (!$this->canBeBootstrapped()) {
             throw new \Exception('Your craft path could not be found.');
         }
         $this->bootstrap();
     }
 }
開發者ID:mattstauffer,項目名稱:craft-cli,代碼行數:20,代碼來源:Application.php

示例10: onCommand

 public function onCommand(ConsoleCommandEvent $event)
 {
     $composer_json_path = 'composer.json';
     if (file_exists($composer_json_path)) {
         return;
     }
     /** @var QuestionHelper $questionHelper */
     $questionHelper = $event->getCommand()->getHelper('question');
     $question = new ConfirmationQuestion('Composer has not been initialized, initialize composer now? [yes]: ', true);
     if (!$questionHelper->ask($event->getInput(), $event->getOutput(), $question)) {
         $event->getOutput()->writeln('Skipping composer init, if the command fails then you should try initializing composer.');
         return;
     }
     /** @var InitHelper $initHelper */
     $initHelper = $event->getCommand()->getHelper('composer init');
     if ($initHelper->initComposer($event->getOutput())) {
         $event->getOutput()->writeln("Composer initialization failed.");
         $event->getOutput()->writeln("Please initialize a composer package manually before trying again.");
         $event->disableCommand();
         $event->stopPropagation();
     }
 }
開發者ID:quickstrap,項目名稱:quickstrap,代碼行數:22,代碼來源:ComposerSetupSubscriber.php

示例11: showWelcomeMessage

 /**
  * @param ConsoleCommandEvent $event
  */
 public function showWelcomeMessage(ConsoleCommandEvent $event)
 {
     /* @var Command $command */
     $command = $event->getCommand();
     /* @var DrupalStyle $io */
     $io = $event->getOutput();
     $application = $command->getApplication();
     $translatorHelper = $application->getTranslator();
     $welcomeMessageKey = 'commands.' . str_replace(':', '.', $command->getName()) . '.welcome';
     $welcomeMessage = $translatorHelper->trans($welcomeMessageKey);
     if ($welcomeMessage != $welcomeMessageKey) {
         $io->text($welcomeMessage);
     }
 }
開發者ID:neelam-chaudhary,項目名稱:DrupalConsole,代碼行數:17,代碼來源:ShowWelcomeMessageListener.php

示例12: showMessage

 /**
  * @param ConsoleCommandEvent $event
  */
 public function showMessage(ConsoleCommandEvent $event)
 {
     /** @var \Drupal\AppConsole\Command\Command $command */
     $command = $event->getCommand();
     $output = $event->getOutput();
     $application = $command->getApplication();
     $messageHelper = $application->getHelperSet()->get('message');
     /* @var TranslatorHelper */
     $translatorHelper = $application->getHelperSet()->get('translator');
     $welcomeMessageKey = 'commands.' . str_replace(':', '.', $command->getName()) . '.welcome';
     $welcomeMessage = $translatorHelper->trans($welcomeMessageKey);
     if ($welcomeMessage != $welcomeMessageKey) {
         $messageHelper->showMessage($output, $welcomeMessage);
     }
 }
開發者ID:amira2r,項目名稱:DrupalConsole,代碼行數:18,代碼來源:ShowWelcomeMessageListener.php

示例13: showTips

 /**
  * @param ConsoleCommandEvent $event
  */
 public function showTips(ConsoleCommandEvent $event)
 {
     /* @var Command $command */
     $command = $event->getCommand();
     $input = $command->getDefinition();
     /* @var DrupalStyle $io */
     $io = $event->getOutput();
     $application = $command->getApplication();
     $translatorHelper = $application->getTranslator();
     $learning = $input->hasOption('learning') ? $input->getOption('learning') : false;
     // pick randomly one of the tips (5 tips as maximum).
     $tips = $this->get_tip($translatorHelper, $command);
     if ($learning && $tips) {
         $io->commentBlock($tips);
     }
 }
開發者ID:killua99,項目名稱:DrupalConsole,代碼行數:19,代碼來源:ShowTipsListener.php

示例14: onCommand

 public function onCommand(ConsoleCommandEvent $event)
 {
     $output = $event->getOutput();
     $input = new ArgvInput();
     try {
         $input->bind($this->getDefinition());
     } catch (\RuntimeException $e) {
     }
     $delay = filter_var($input->getOption('delay'), FILTER_VALIDATE_INT);
     if ($delay > 0) {
         $wakeupAt = time() + mt_rand(1, $delay);
         $output->writeln('<comment>Waiting until ' . date('Y-m-d H:i:s', $wakeupAt) . ' eRepublik time.</comment>');
         time_sleep_until($wakeupAt);
     }
     $this->configPath = $input->getOption('config');
     $this->loadConfig();
 }
開發者ID:erpk,項目名稱:erbot,代碼行數:17,代碼來源:Application.php

示例15: 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


注:本文中的Symfony\Component\Console\Event\ConsoleCommandEvent::getOutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。