{% extends "base/class.php.twig" %} {% block file_path %} \Drupal\{{module}}\Controller\{{ class_name }}. {% endblock %} {% block namespace_class %} namespace Drupal\{{module}}\Controller; {% endblock %} {% block use_class %} use Drupal\Core\Controller\ControllerBase; {% if services is not empty %} use Symfony\Component\DependencyInjection\ContainerInterface; {% endif %} {% endblock %} {% block class_declaration %} /** * Class {{ class_name }}. * * @package Drupal\{{ module }}\Controller */ class {{ class_name }} extends ControllerBase {% endblock %} {% block class_construct %} {% if services is not empty %} /** * {@inheritdoc} */ public function __construct({{ servicesAsParameters(services)|join(', ') }}) { {{ serviceClassInitialization(services) }} } {% endif %} {% endblock %} {% block class_create %} {% if services is not empty %} /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( {{ serviceClassInjection(services) }} ); } {% endif %} {% endblock %} {% block class_methods %} {% for route in routes %} /** * {{ route.method | capitalize }}. * * @return string * Return Hello string. */ public function {{route.method}}({{ argumentsFromRoute(route.path)|join(', ') }}) { {% if argumentsFromRoute(route.path) is not empty %} return [ '#type' => 'markup', '#markup' => $this->t('Implement method: {{route.method}} with parameter(s): {{ argumentsFromRoute(route.path)|join(', ') }}'), ]; {% else %} return [ '#type' => 'markup', '#markup' => $this->t('Implement method: {{route.method}}') ]; {% endif %} } {% endfor %} {% endblock %}