3 namespace DrupalCodeGenerator\Command\Drupal_8\Service;
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;
12 * Implements d8:service:twig-extension command.
14 class TwigExtension extends BaseGenerator {
16 protected $name = 'd8:service:twig-extension';
17 protected $description = 'Generates Twig extension service';
18 protected $alias = 'twig-extension';
23 protected function interact(InputInterface $input, OutputInterface $output) {
24 $questions = Utils::defaultQuestions();
25 $default_class = function ($vars) {
26 return Utils::camelize($vars['name'] . 'TwigExtension');
28 $questions['class'] = new Question('Class', $default_class);
30 $this->collectVars($input, $output, $questions);
33 ->path('src/{class}.php')
34 ->template('d8/service/twig-extension.twig');
36 $this->addServicesFile()
37 ->template('d8/service/twig-extension.services.twig');