Version 1
[yaffs-website] / vendor / drupal / console / templates / module / src / Controller / controller.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{module}}\Controller\{{ class_name }}.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{module}}\Controller;
9 {% endblock %}
10
11 {% block use_class %}
12 use Drupal\Core\Controller\ControllerBase;
13 {% if services is not empty %}
14 use Symfony\Component\DependencyInjection\ContainerInterface;
15 {% endif %}
16 {% endblock %}
17 {% block class_declaration %}
18 /**
19  * Class {{ class_name }}.
20  *
21  * @package Drupal\{{ module }}\Controller
22  */
23 class {{ class_name }} extends ControllerBase {% endblock %}
24 {% block class_construct %}
25 {% if services is not empty %}
26
27   /**
28    * {@inheritdoc}
29    */
30   public function __construct({{ servicesAsParameters(services)|join(', ') }}) {
31 {{ serviceClassInitialization(services) }}
32   }
33 {% endif %}
34 {% endblock %}
35 {% block class_create %}
36 {% if services is not empty %}
37
38   /**
39    * {@inheritdoc}
40    */
41   public static function create(ContainerInterface $container) {
42     return new static(
43 {{ serviceClassInjection(services) }}
44     );
45   }
46
47 {% endif %}
48 {% endblock %}
49 {% block class_methods %}
50 {% for route in routes %}
51   /**
52    * {{ route.method | capitalize }}.
53    *
54    * @return string
55    *   Return Hello string.
56    */
57   public function {{route.method}}({{ argumentsFromRoute(route.path)|join(', ') }}) {
58 {% if argumentsFromRoute(route.path) is not empty %}
59     return [
60       '#type' => 'markup',
61       '#markup' => $this->t('Implement method: {{route.method}} with parameter(s): {{ argumentsFromRoute(route.path)|join(', ') }}'),
62     ];
63 {% else %}
64     return [
65       '#type' => 'markup',
66       '#markup' => $this->t('Implement method: {{route.method}}')
67     ];
68 {% endif %}
69   }
70 {% endfor %}
71 {% endblock %}