Skip to content

Commit 032f80e

Browse files
hjuarez20enzolutions
authored andcommitted
[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
1 parent 6fb6004 commit 032f80e

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

templates/module/src/Plugin/Block/block.php.twig

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,18 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
4040
* The plugin_id for the plugin instance.
4141
* @param string $plugin_definition
4242
* The plugin implementation definition.
43+
{% if services is not empty %}
44+
{% for service in services %}
45+
* @param \{{ service.class }} ${{service.machine_name}}
46+
* The {{service.short}} definition.
47+
{% endfor %}
48+
{% endif %}
4349
*/
4450
public function __construct(
4551
array $configuration,
4652
$plugin_id,
4753
$plugin_definition,
48-
{{ servicesAsParameters(services)|join(', \n\t') }}
54+
{{ servicesAsParameters(services)|join(',\n ') }}
4955
) {
5056
parent::__construct($configuration, $plugin_id, $plugin_definition);
5157
{{ serviceClassInitialization(services) }}
@@ -54,6 +60,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
5460
{% endblock %}
5561
{% block class_create %}
5662
{% if services is not empty %}
63+
5764
/**
5865
* {@inheritdoc}
5966
*/
@@ -65,6 +72,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
6572
{{ serviceClassInjection(services) }}
6673
);
6774
}
75+
6876
{% endif %}
6977
{% endblock %}
7078
{% block class_methods %}
@@ -75,9 +83,9 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
7583
public function defaultConfiguration() {
7684
return [
7785
{% for input in inputs %}
78-
{% if input.default_value is defined and input.default_value|length %}
86+
{% if input.default_value is defined and input.default_value|length %}
7987
'{{ input.name }}' => {{ input.default_value }},
80-
{% endif %}
88+
{% endif %}
8189
{% endfor %}
8290
] + parent::defaultConfiguration();
8391
}
@@ -91,7 +99,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
9199
'#type' => '{{ input.type }}',
92100
'#title' => $this->t('{{ input.label|escape }}'),
93101
{% if input.description is defined and input.description is not empty %}
94-
'#description' => $this->t('{{ input.description|e }}'),
102+
'#description' => $this->t('{{ input.description|e }}'),
95103
{% endif %}
96104
{% if input.options is defined and input.options|length %}
97105
'#options' => {{ input.options }},
@@ -128,7 +136,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
128136
public function build() {
129137
$build = [];
130138
{% for input in inputs %}
131-
$build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}']. '</p>';
139+
$build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}'] . '</p>';
132140
{% else %}
133141
$build['{{plugin_id}}']['#markup'] = 'Implement {{class_name}}.';
134142
{% endfor %}

0 commit comments

Comments
 (0)