3 namespace DrupalCodeGenerator\Command\Other;
5 use DrupalCodeGenerator\Command\BaseGenerator;
6 use DrupalCodeGenerator\Utils;
7 use Symfony\Component\Console\Input\InputInterface;
8 use Symfony\Component\Console\Output\OutputInterface;
9 use Symfony\Component\Console\Question\ConfirmationQuestion;
10 use Symfony\Component\Console\Question\Question;
13 * Implements other:drupal-console-command command.
15 class DrupalConsoleCommand extends BaseGenerator {
17 protected $name = 'other:drupal-console-command';
18 protected $description = 'Generates Drupal Console command';
19 protected $alias = 'drupal-console-command';
24 protected function interact(InputInterface $input, OutputInterface $output) {
26 $questions = Utils::defaultQuestions() + [
27 'command_name' => new Question('Command name', '{machine_name}:example'),
28 'description' => new Question('Command description', 'Command description.'),
29 'container_aware' => new ConfirmationQuestion('Make the command aware of the drupal site installation?', TRUE),
32 $vars = &$this->collectVars($input, $output, $questions);
33 $vars['class'] = Utils::camelize(str_replace(':', '_', $vars['command_name'])) . 'Command';
34 $vars['command_trait'] = $vars['container_aware'] ? 'ContainerAwareCommandTrait' : 'CommandTrait';
37 ->path('src/Command/{class}.php')
38 ->template('other/drupal-console-command.twig');