e2c33277a214c3bdf91bf0128b79a7f91cd3b336
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Template.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Drupal_8;
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 d8:template command.
14  */
15 class Template extends BaseGenerator {
16
17   protected $name = 'd8:template';
18   protected $description = 'Generates a template';
19   protected $alias = 'template';
20
21   /**
22    * {@inheritdoc}
23    */
24   protected function interact(InputInterface $input, OutputInterface $output) {
25     $questions = Utils::defaultQuestions();
26     $questions['template_name'] = new Question('Template name', 'example');
27     $questions['create_theme'] = new ConfirmationQuestion('Create theme hook?', TRUE);
28     $questions['create_preprocess'] = new ConfirmationQuestion('Create preprocess hook?', TRUE);
29
30     $vars = $this->collectVars($input, $output, $questions);
31
32     $this->addFile()
33       ->path('templates/{template_name}.html.twig')
34       ->template('d8/template-template.twig');
35
36     if ($vars['create_theme'] || $vars['create_preprocess']) {
37       $this->addFile()
38         ->path('{machine_name}.module')
39         ->template('d8/template-module.twig')
40         ->action('append')
41         ->headerSize(7);
42     }
43   }
44
45 }