Yaffs site version 1.1
[yaffs-website] / vendor / drupal / console / templates / module / src / Plugin / skeleton.php.twig
1 {% extends "base/class.php.twig" %}
2
3 {% block file_path %}
4 \Drupal\{{module}}\Plugin\{{ plugin }}\{{class_name}}.
5 {% endblock %}
6
7 {% block namespace_class %}
8 namespace Drupal\{{module}}\Plugin\{{ plugin }};
9 {% endblock %}
10
11 {% block use_class %}
12 {% if pluginInterface is not empty %}
13 use {{ pluginInterface }};
14 {% endif %}
15
16 {% if services is not empty %}
17 use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
18 use Symfony\Component\DependencyInjection\ContainerInterface;
19 {% endif %}
20 {% endblock %}
21
22 {% block class_declaration %}
23 {% if pluginAnnotation is not empty %}
24 /**
25  * @{{ plugin_annotation }}(
26 {% for property in pluginAnnotationProperties %}
27 {% if property.name == 'id' %}
28  *  id = "{{- plugin_id }}",
29 {% elseif property.type == "\\Drupal\\Core\\Annotation\\Translation" %}
30  *  {{ property.name }} = @Translation("{{property.description}}"),
31 {% else %}
32  *  {{ property.name }} = "{{ property.type }}",
33 {% endif %}
34 {% endfor %}
35  * )
36  */
37 {% endif %}
38 class {{class_name}} implements {% if plugin_interface is not empty %} {{ plugin_interface }} {% endif %}{% if services is not empty %}, ContainerFactoryPluginInterface {% endif %}{% endblock %}
39 {% block class_construct %}
40 {% if services is not empty %}
41   /**
42    * Constructs a new {{class_name}} object.
43    *
44    * @param array $configuration
45    *   A configuration array containing information about the plugin instance.
46    * @param string $plugin_id
47    *   The plugin_id for the plugin instance.
48    * @param string $plugin_definition
49    *   The plugin implementation definition.
50    */
51   public function __construct(
52         array $configuration,
53         $plugin_id,
54         $plugin_definition,
55         {{ servicesAsParameters(services)|join(', \n\t') }}
56   ) {
57     parent::__cons truct($configuration, $plugin_id, $plugin_definition);
58 {{ serviceClassInitialization(services) }}
59   }
60 {% endif %}
61 {% endblock %}
62 {% block class_create %}
63 {% if services is not empty %}
64   /**
65    * {@inheritdoc}
66    */
67   public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
68     return new static(
69       $configuration,
70       $plugin_id,
71       $plugin_definition,
72 {{ serviceClassInjection(services) }}
73     );
74   }
75 {% endif %}
76 {% endblock %}
77 {% block class_methods %}
78
79     /**
80     * {@inheritdoc}
81     */
82     public function build() {
83     $build = [];
84
85     // Implement your logic
86
87     return $build;
88     }
89
90   {% for method in pluginInterfaceMethods %}
91     /**
92       * {@inheritdoc}
93       */
94       {{ method.declaration }} {
95         // {{ method.description }}
96       }
97   {% endfor %}
98 {% endblock %}