Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / src / Command / Drupal_8 / Service / ParamConverter.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:param-converter command.
13  */
14 class ParamConverter extends BaseGenerator {
15
16   protected $name = 'd8:service:param-converter';
17   protected $description = 'Generates a param converter service';
18   protected $alias = 'param-converter';
19
20   /**
21    * {@inheritdoc}
22    */
23   protected function interact(InputInterface $input, OutputInterface $output) {
24     $questions = Utils::defaultQuestions();
25     $questions['parameter_type'] = new Question('Parameter type', 'example');
26     $default_class = function ($vars) {
27       return Utils::camelize($vars['parameter_type'] . 'ParamConverter');
28     };
29     $questions['class'] = new Question('Class', $default_class);
30
31     $vars = &$this->collectVars($input, $output, $questions);
32     $vars['controller_class'] = Utils::camelize($vars['machine_name'] . 'Controller');
33
34     $this->addFile()
35       ->path('src/{class}.php')
36       ->template('d8/service/param-converter.twig');
37
38     $this->addServicesFile()
39       ->path('{machine_name}.services.yml')
40       ->template('d8/service/param-converter.services.twig');
41   }
42
43 }