annotate vendor/chi-teck/drupal-code-generator/templates/other/dcg-command.twig @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
rev   line source
Chris@0 1 <?php
Chris@0 2
Chris@0 3 // @DCG Place this file to $HOME/.dcg/Command{{ path }} directory.
Chris@0 4
Chris@0 5 namespace {{ namespace }};
Chris@0 6
Chris@0 7 use DrupalCodeGenerator\Command\BaseGenerator;
Chris@0 8 use DrupalCodeGenerator\Utils;
Chris@0 9 use Symfony\Component\Console\Input\InputInterface;
Chris@0 10 use Symfony\Component\Console\Output\OutputInterface;
Chris@0 11 use Symfony\Component\Console\Question\Question;
Chris@0 12
Chris@0 13 /**
Chris@0 14 * Implements {{ name }} command.
Chris@0 15 */
Chris@0 16 class {{ class }} extends BaseGenerator {
Chris@0 17
Chris@0 18 protected $name = '{{ name }}';
Chris@0 19 protected $description = '{{ description }}';
Chris@0 20 protected $alias = '{{ alias }}';
Chris@0 21 protected $templatePath = __DIR__;
Chris@0 22
Chris@0 23 /**
Chris@0 24 * {@inheritdoc}
Chris@0 25 */
Chris@0 26 protected function interact(InputInterface $input, OutputInterface $output) {
Chris@0 27 // Ask the user some questions.
Chris@0 28 $questions = Utils::defaultQuestions();
Chris@0 29 $default_class = function ($vars) {
Chris@4 30 return Utils::camelize($vars['name']) . 'Example';
Chris@0 31 };
Chris@0 32 $questions['class'] = new Question('Class', $default_class);
Chris@0 33
Chris@0 34 $this->collectVars($input, $output, $questions);
Chris@0 35
Chris@0 36 // @DCG The template should be located under directory specified in
Chris@0 37 // $self::templatePath property.
Chris@0 38 $this->addFile()
Chris@0 39 ->path('src/{class}.php')
Chris@0 40 ->template('{{ template_name }}');
Chris@0 41 }
Chris@0 42
Chris@0 43 }