{% extends "base/class.php.twig" %} {% block file_path %} \Drupal\{{module}}\Plugin\{{ plugin }}\{{class_name}}. {% endblock %} {% block namespace_class %} namespace Drupal\{{module}}\{{ namespace }}; {% endblock %} {% block use_class %} {% if pluginInterface is not empty %} use {{ pluginInterface }}; {% endif %} {% if services is not empty %} use Drupal\Core\Plugin\ContainerFactoryPluginInterface; use Symfony\Component\DependencyInjection\ContainerInterface; {% endif %} {% endblock %} {% block use_class_services %} {% endblock %} {% block class_declaration %} {% if pluginAnnotation is not empty %} /** * @{{ plugin_annotation }}( {% for property in pluginAnnotationProperties %} {% if property.name == 'id' %} * id = "{{- id }}", {% elseif property.type == "\\Drupal\\Core\\Annotation\\Translation" %} * {{ property.name }} = @Translation("{{label}}"), {% else %} * {{ property.name }} = "{{ property.type }}", {% endif %} {% endfor %} * ) */ {% endif %} class {{class_name}} implements {% if plugin_interface is not empty %}{{ plugin_interface }}{% endif %}{% if services is not empty %}, ContainerFactoryPluginInterface {% endif %}{% endblock %} {% block class_create %} {% if services is not empty %} /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { $instance = new static($configuration, $plugin_id, $plugin_definition); {{ serviceClassInjectionNoOverride(services) }} return $instance; } {% endif %} {% endblock %} {% block class_methods %} /** * {@inheritdoc} */ public function build() { $build = []; // Implement your logic return $build; } {% for method in pluginInterfaceMethods %} /** * {@inheritdoc} */ {{ method.declaration }} { } {% endfor %} {% endblock %}