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


PHP ConsoleCommandEvent::disableCommand方法代码示例

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


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

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

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

示例4: onConsoleCommand

 /**
  * Disabling runs members of chains and launching chains of commands.
  *
  * @param   ConsoleCommandEvent $event
  */
 public function onConsoleCommand(ConsoleCommandEvent $event)
 {
     $command = $event->getCommand();
     $commandName = $command->getName();
     $application = $command->getApplication();
     if (!$this->manager->isInitialized()) {
         $this->manager->init($application);
     }
     if ($this->manager->isMember($commandName)) {
         $event->disableCommand();
         $event->stopPropagation();
         $mainCommands = $this->manager->getMainCommands($commandName);
         $event->getOutput()->writeln(sprintf('<error>Error: "%s" command is a member of %s command%s chain and cannot be executed on its own.</error>', $commandName, implode(', ', array_map(function ($name) {
             return '"' . $name . '"';
         }, $mainCommands)), count($mainCommands) > 1 ? 's' : ''));
     }
     if ($this->manager->hasChains($commandName)) {
         $this->manager->runChain($command, $event->getInput());
         $event->disableCommand();
         $event->stopPropagation();
     }
 }
开发者ID:relo-san,项目名称:CommandChainTest,代码行数:27,代码来源:CommandListener.php

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

示例6: showGenerateDoc

 /**
  * @param ConsoleCommandEvent $event
  * @return void
  */
 public function showGenerateDoc(ConsoleCommandEvent $event)
 {
     /* @var \Drupal\Console\Command\Command $command */
     $command = $event->getCommand();
     $application = $command->getApplication();
     $input = $command->getDefinition();
     $options = $input->getOptions();
     $arguments = $input->getArguments();
     if (isset($options['generate-doc'])) {
         foreach ($this->skipOptions as $remove_option) {
             unset($options[$remove_option]);
         }
         $parameters = ['options' => $options, 'arguments' => $arguments, 'command' => $command->getName(), 'aliases' => $command->getAliases(), 'examples' => [], 'messages' => ['command_description' => sprintf($application->trans('commands.generate.doc.command.command_description'), $command->getName(), $command->getDescription()), 'usage' => $application->trans('commands.generate.doc.command.usage'), 'options' => $application->trans('commands.generate.doc.command.options'), 'option' => $application->trans('commands.generate.doc.command.options'), 'details' => $application->trans('commands.generate.doc.command.details'), 'arguments' => $application->trans('commands.generate.doc.command.arguments'), 'argument' => $application->trans('commands.generate.doc.command.argument')]];
         $renderedDoc = $application->getRenderHelper()->render('gitbook/generate-doc.md.twig', $parameters);
         $output = $event->getOutput();
         $output->writeln($renderedDoc);
         $event->disableCommand();
     }
 }
开发者ID:neelam-chaudhary,项目名称:DrupalConsole,代码行数:23,代码来源:ShowGenerateDocListener.php

示例7: validateDependencies

 /**
  * @param ConsoleCommandEvent $event
  */
 public function validateDependencies(ConsoleCommandEvent $event)
 {
     /* @var Command $command */
     $command = $event->getCommand();
     /* @var DrupalStyle $io */
     $io = $event->getOutput();
     $application = $command->getApplication();
     $translatorHelper = $application->getTranslator();
     if (!$command instanceof Command) {
         return;
     }
     if ($dependencies = $command->getDependencies()) {
         foreach ($dependencies as $dependency) {
             if (!$application->getValidator()->isModuleInstalled($dependency)) {
                 $errorMessage = sprintf($translatorHelper->trans('commands.common.errors.module-dependency'), $dependency);
                 $io->error($errorMessage);
                 $event->disableCommand();
             }
         }
     }
 }
开发者ID:blasoliva,项目名称:DrupalConsole,代码行数:24,代码来源:ValidateDependenciesListener.php

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


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