Skip to content
Permalink
Browse files

[generate:plugin:skeleton] Fixed namespace (#4028)

  • Loading branch information...
harold20 authored and enzolutions committed May 10, 2019
1 parent 404a026 commit 245767a8643f77a21ecc6448b12427b1ac04351f
@@ -174,6 +174,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
'class_name' => $className,
'services' => $buildServices,
'plugin_metadata' => $pluginMetaData,
'id' => $this->stringConverter->camelCaseToUnderscore($className),
'label' => $this->stringConverter->camelCaseToHuman($className)
]);
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
@@ -39,6 +39,7 @@ public function generate(array $parameters)
$parameters['plugin_annotation'] = array_pop(explode('\\', $pluginMetaData['pluginAnnotation']));
$parameters['plugin_interface'] = array_pop(explode('\\', $pluginMetaData['pluginInterface']));
$parameters['namespace'] = str_replace('/', '\\', $pluginMetaData['subdir']);
$this->renderFile(
'module/src/Plugin/skeleton.php.twig',
@@ -5,7 +5,7 @@
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module}}\Plugin\{{ plugin }};
namespace Drupal\{{module}}\{{ namespace }};
{% endblock %}

{% block use_class %}
@@ -25,17 +25,17 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @{{ plugin_annotation }}(
{% for property in pluginAnnotationProperties %}
{% if property.name == 'id' %}
* id = "{{- plugin_id }}",
* id = "{{- id }}",
{% elseif property.type == "\\Drupal\\Core\\Annotation\\Translation" %}
* {{ property.name }} = @Translation("{{property.description}}"),
* {{ 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 %}
class {{class_name}} implements {% if plugin_interface is not empty %}{{ plugin_interface }}{% endif %}{% if services is not empty %}, ContainerFactoryPluginInterface {% endif %}{% endblock %}
{% block class_construct %}
{% if services is not empty %}
/**
@@ -61,38 +61,38 @@ class {{class_name}} implements {% if plugin_interface is not empty %} {{ plugin
{% endblock %}
{% block class_create %}
{% if services is not empty %}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
{{ serviceClassInjection(services) }}
);
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static(
$configuration,
$plugin_id,
$plugin_definition,
{{ serviceClassInjection(services) }}
);
}
{% endif %}
{% endblock %}
{% block class_methods %}

/**
* {@inheritdoc}
*/
* {@inheritdoc}
*/
public function build() {
$build = [];

// Implement your logic

return $build;
}

{% for method in pluginInterfaceMethods %}

/**
* {@inheritdoc}
*/
{{ method.declaration }} {
* {@inheritdoc}
*/
{{ method.declaration }} {

}
}
{% endfor %}
{% endblock %}

0 comments on commit 245767a

Please sign in to comment.
You can’t perform that action at this time.