This repository has been archived on 2025-01-19. You can view files and clone it, but cannot push or open issues or pull requests.
drupalcampbristol/vendor/chi-teck/drupal-code-generator/templates/other/dcg-command.twig

44 lines
1.2 KiB
Twig
Raw Normal View History

2018-11-23 12:29:20 +00:00
<?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 }}');
}
}