Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / other / dcg-command.twig
1 <?php
2
3 // @DCG Place this file to $HOME/.dcg/Command{{ path }} directory.
4
5 namespace {{ namespace }};
6
7 use DrupalCodeGenerator\Command\BaseGenerator;
8 use DrupalCodeGenerator\Utils;
9 use Symfony\Component\Console\Input\InputInterface;
10 use Symfony\Component\Console\Output\OutputInterface;
11 use Symfony\Component\Console\Question\Question;
12
13 /**
14  * Implements {{ name }} command.
15  */
16 class {{ class }} extends BaseGenerator {
17
18   protected $name = '{{ name }}';
19   protected $description = '{{ description }}';
20   protected $alias = '{{ alias }}';
21   protected $templatePath = __DIR__;
22
23   /**
24    * {@inheritdoc}
25    */
26   protected function interact(InputInterface $input, OutputInterface $output) {
27     // Ask the user some questions.
28     $questions = Utils::defaultQuestions();
29     $default_class = function ($vars) {
30       return Utils::camelize($vars['name']) . 'Example';
31     };
32     $questions['class'] = new Question('Class', $default_class);
33
34     $this->collectVars($input, $output, $questions);
35
36     // @DCG The template should be located under directory specified in
37     // $self::templatePath property.
38     $this->addFile()
39       ->path('src/{class}.php')
40       ->template('{{ template_name }}');
41   }
42
43 }