b9121fdab85306cd03b8005c6e6b53bd6341f776
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Service / TwigExtension.php
1 <?php
2
3 namespace DrupalCodeGenerator\Command\Drupal_8\Service;
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\Question;
10
11 /**
12  * Implements d8:service:twig-extension command.
13  */
14 class TwigExtension extends BaseGenerator {
15
16   protected $name = 'd8:service:twig-extension';
17   protected $description = 'Generates Twig extension service';
18   protected $alias = 'twig-extension';
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function interact(InputInterface $input, OutputInterface $output) {
24     $questions = Utils::defaultQuestions();
25     $default_class = function ($vars) {
26       return Utils::camelize($vars['name'] . 'TwigExtension');
27     };
28     $questions['class'] = new Question('Class', $default_class);
29
30     $this->collectVars($input, $output, $questions);
31
32     $this->addFile()
33       ->path('src/{class}.php')
34       ->template('d8/service/twig-extension.twig');
35
36     $this->addServicesFile()
37       ->template('d8/service/twig-extension.services.twig');
38   }
39
40 }