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