Mercurial > hg > cmmr2012-drupal-site
diff vendor/chi-teck/drupal-code-generator/templates/other/dcg-command.twig @ 0:c75dbcec494b
Initial commit from drush-created site
author | Chris Cannam |
---|---|
date | Thu, 05 Jul 2018 14:24:15 +0000 |
parents | |
children | a9cd425dd02b |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/vendor/chi-teck/drupal-code-generator/templates/other/dcg-command.twig Thu Jul 05 14:24:15 2018 +0000 @@ -0,0 +1,43 @@ +<?php + +// @DCG Place this file to $HOME/.dcg/Command{{ path }} directory. + +namespace {{ namespace }}; + +use DrupalCodeGenerator\Command\BaseGenerator; +use DrupalCodeGenerator\Utils; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Console\Question\Question; + +/** + * Implements {{ name }} command. + */ +class {{ class }} extends BaseGenerator { + + protected $name = '{{ name }}'; + protected $description = '{{ description }}'; + protected $alias = '{{ alias }}'; + protected $templatePath = __DIR__; + + /** + * {@inheritdoc} + */ + protected function interact(InputInterface $input, OutputInterface $output) { + // Ask the user some questions. + $questions = Utils::defaultQuestions(); + $default_class = function ($vars) { + return Utils::camelize($vars['name'] . 'Example'); + }; + $questions['class'] = new Question('Class', $default_class); + + $this->collectVars($input, $output, $questions); + + // @DCG The template should be located under directory specified in + // $self::templatePath property. + $this->addFile() + ->path('src/{class}.php') + ->template('{{ template_name }}'); + } + +}