02621f104be84f8d67cc19091bb1ee1de5bfbe31
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Other / DrupalConsoleCommand.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Other;
4
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;
11
12 /**
13  * Implements other:drupal-console-command command.
14  */
15 class DrupalConsoleCommand extends BaseGenerator {
16
17   protected $name = 'other:drupal-console-command';
18   protected $description = 'Generates Drupal Console command';
19   protected $alias = 'drupal-console-command';
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function interact(InputInterface $input, OutputInterface $output) {
25
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),
30     ];
31
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';
35
36     $this->addFile()
37       ->path('src/Command/{class}.php')
38       ->template('other/drupal-console-command.twig');
39   }
40
41 }