5 * Contains \Drupal\Console\Command\Generate\HelpCommand.
8 namespace Drupal\Console\Command\Generate;
10 use Symfony\Component\Console\Input\InputInterface;
11 use Symfony\Component\Console\Input\InputOption;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Console\Command\Command;
14 use Drupal\Console\Generator\HelpGenerator;
15 use Drupal\Console\Command\Shared\ModuleTrait;
16 use Drupal\Console\Command\Shared\ConfirmationTrait;
17 use Drupal\Console\Core\Command\Shared\CommandTrait;
18 use Drupal\Console\Extension\Manager;
19 use Drupal\Console\Core\Style\DrupalStyle;
20 use Drupal\Console\Utils\Site;
21 use Drupal\Console\Core\Utils\ChainQueue;
23 class HelpCommand extends Command
27 use ConfirmationTrait;
42 protected $extensionManager;
47 protected $chainQueue;
51 * HelpCommand constructor.
53 * @param HelpGenerator $generator
55 * @param Manager $extensionManager
56 * @param ChainQueue $chainQueue
58 public function __construct(
59 HelpGenerator $generator,
61 Manager $extensionManager,
62 ChainQueue $chainQueue
64 $this->generator = $generator;
66 $this->extensionManager = $extensionManager;
67 $this->chainQueue = $chainQueue;
68 parent::__construct();
71 protected function configure()
74 ->setName('generate:help')
75 ->setDescription($this->trans('commands.generate.help.description'))
76 ->setHelp($this->trans('commands.generate.help.help'))
80 InputOption::VALUE_REQUIRED,
81 $this->trans('commands.common.options.module')
86 InputOption::VALUE_OPTIONAL,
87 $this->trans('commands.generate.module.options.description')
94 protected function execute(InputInterface $input, OutputInterface $output)
96 $io = new DrupalStyle($input, $output);
98 // @see use Drupal\Console\Command\ConfirmationTrait::confirmGeneration
99 if (!$this->confirmGeneration($io)) {
103 $module = $input->getOption('module');
105 if ($this->extensionManager->validateModuleFunctionExist($module, $module . '_help')) {
106 throw new \Exception(
108 $this->trans('commands.generate.help.messages.help-already-implemented'),
114 $description = $input->getOption('description');
118 ->generate($module, $description);
120 $this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
125 protected function interact(InputInterface $input, OutputInterface $output)
127 $io = new DrupalStyle($input, $output);
129 $this->site->loadLegacyFile('/core/includes/update.inc');
130 $this->site->loadLegacyFile('/core/includes/schema.inc');
132 $module = $input->getOption('module');
134 // @see Drupal\Console\Command\ModuleTrait::moduleQuestion
135 $module = $this->moduleQuestion($io);
136 $input->setOption('module', $module);
139 $description = $input->getOption('description');
141 $description = $io->ask(
142 $this->trans('commands.generate.module.questions.description'),
146 $input->setOption('description', $description);