v1/vendor/chi-teck/drupal-code-generator/templates/console/dcg-command/command.twig

32 lines
769 B
Twig

<?php
namespace {{ namespace }};
use DrupalCodeGenerator\Command\ModuleGenerator;
/**
* Implements {{ command_name }} command.
*/
class {{ class }} extends ModuleGenerator {
protected string $name = '{{ command_name }}';
protected string $description = '{{ description }}';
protected string $alias = '{{ alias }}';
protected string $templatePath = __DIR__;
/**
* {@inheritdoc}
*/
protected function generate(array &$vars) :void {
$this->collectDefault($vars);
$vars['class'] = $this->ask('Class', '{machine_name|camelize}');
// @DCG The template should be located under directory specified in
// $this->templatePath variable.
$this->addFile()
->path('src/{class}.php')
->template('{{ template_name }}');
}
}