
| Current Path : /var/www/html/vendor/chi-teck/drupal-code-generator/src/Command/ |
Linux ift1.ift-informatik.de 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 |
| Current File : /var/www/html/vendor/chi-teck/drupal-code-generator/src/Command/Controller.php |
<?php declare(strict_types=1);
namespace DrupalCodeGenerator\Command;
use DrupalCodeGenerator\Application;
/**
* Implements controller command.
*/
final class Controller extends ModuleGenerator {
protected string $name = 'controller';
protected string $description = 'Generates a controller';
protected string $templatePath = Application::TEMPLATE_PATH . '/controller';
/**
* {@inheritdoc}
*/
protected function generate(array &$vars): void {
$this->collectDefault($vars);
$vars['class'] = $this->ask('Class', '{machine_name|camelize}Controller');
$this->collectServices($vars, FALSE);
if ($this->confirm('Would you like to create a route for this controller?')) {
$vars['route_name'] = $this->ask('Route name', '{machine_name}.example');
$vars['route_path'] = $this->ask('Route path', '/{machine_name|u2h}/example');
$vars['route_title'] = $this->ask('Route title', 'Example');
$vars['route_permission'] = $this->ask('Route permission', 'access content');
$this->addFile('{machine_name}.routing.yml', 'route')->appendIfExists();
}
$this->addFile('src/Controller/{class}.php', 'controller');
}
}