Skip to content
Permalink
Browse files

[generate:plugin:block] Added code standard (#4099)

* [update:execute] Fixed update table

* Revert "Merge remote-tracking branch 'upstream/master'"

This reverts commit ddf7739, reversing
changes made to a95b7e6.

* [generate:plugin:block] Added code standard
  • Loading branch information...
harold20 authored and enzolutions committed Jun 24, 2019
1 parent 6fb6004 commit 032f80e3dc93f09c4a14cb7611866767ee71491b
Showing with 13 additions and 5 deletions.
  1. +13 −5 templates/module/src/Plugin/Block/block.php.twig
@@ -40,12 +40,18 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
* The plugin_id for the plugin instance.
* @param string $plugin_definition
* The plugin implementation definition.
{% if services is not empty %}
{% for service in services %}
* @param \{{ service.class }} ${{service.machine_name}}
* The {{service.short}} definition.
{% endfor %}
{% endif %}
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
{{ servicesAsParameters(services)|join(', \n\t') }}
{{ servicesAsParameters(services)|join(',\n ') }}
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
{{ serviceClassInitialization(services) }}
@@ -54,6 +60,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{% endblock %}
{% block class_create %}
{% if services is not empty %}

/**
* {@inheritdoc}
*/
@@ -65,6 +72,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{{ serviceClassInjection(services) }}
);
}

{% endif %}
{% endblock %}
{% block class_methods %}
@@ -75,9 +83,9 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
public function defaultConfiguration() {
return [
{% for input in inputs %}
{% if input.default_value is defined and input.default_value|length %}
{% if input.default_value is defined and input.default_value|length %}
'{{ input.name }}' => {{ input.default_value }},
{% endif %}
{% endif %}
{% endfor %}
] + parent::defaultConfiguration();
}
@@ -91,7 +99,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
'#type' => '{{ input.type }}',
'#title' => $this->t('{{ input.label|escape }}'),
{% if input.description is defined and input.description is not empty %}
'#description' => $this->t('{{ input.description|e }}'),
'#description' => $this->t('{{ input.description|e }}'),
{% endif %}
{% if input.options is defined and input.options|length %}
'#options' => {{ input.options }},
@@ -128,7 +136,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
public function build() {
$build = [];
{% for input in inputs %}
$build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}']. '</p>';
$build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}'] . '</p>';
{% else %}
$build['{{plugin_id}}']['#markup'] = 'Implement {{class_name}}.';
{% endfor %}

0 comments on commit 032f80e

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