159f93af773c566123ec5a7ef06199d8fbcc0462
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / controller.twig
1 {% import 'lib/di.twig' as di %}
2 <?php
3
4 namespace Drupal\{{ machine_name }}\Controller;
5
6 {% sort %}
7 use Drupal\Core\Controller\ControllerBase;
8   {% if services %}
9 use Symfony\Component\DependencyInjection\ContainerInterface;
10 {{ di.use(services) }}
11   {% endif %}
12 {% endsort %}
13
14 /**
15  * Returns responses for {{ name }} routes.
16  */
17 class {{ class }} extends ControllerBase {
18
19 {% if services %}
20 {{ di.properties(services) }}
21
22   /**
23    * The controller constructor.
24    *
25 {{ di.annotation(services) }}
26    */
27   public function __construct({{ di.signature(services) }}) {
28 {{ di.assignment(services) }}
29   }
30
31   /**
32    * {@inheritdoc}
33    */
34   public static function create(ContainerInterface $container) {
35     return new static(
36 {{ di.container(services) }}
37     );
38   }
39
40 {% endif %}
41   /**
42    * Builds the response.
43    */
44   public function build() {
45
46     $build['content'] = [
47       '#type' => 'item',
48       '#markup' => $this->t('It works!'),
49     ];
50
51     return $build;
52   }
53
54 }