Skip to content

Commit

Permalink
Fix block plugin output (#3549)
Browse files Browse the repository at this point in the history
* Corrected block plugin generator output.

* Escape block plugin names and descriptions.

* Fixed output of defaultConfiguration().
  • Loading branch information
damienmckenna authored and jmolivas committed Oct 28, 2017
1 parent 4a3e432 commit 13c437b
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions templates/module/src/Plugin/Block/block.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
* The plugin implementation definition.
*/
public function __construct(
array $configuration,
$plugin_id,
$plugin_definition,
{{ servicesAsParameters(services)|join(', \n\t') }}
array $configuration,
$plugin_id,
$plugin_definition,
{{ servicesAsParameters(services)|join(', \n\t') }}
) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
{{ serviceClassInitialization(services) }}
Expand All @@ -69,18 +69,16 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{% endblock %}
{% block class_methods %}
{% if inputs %}

/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [
{% for input in inputs %}
'{{ input.name }}' => {{ input.default_code }},
{% endfor %}
{% for input in inputs %}
'{{ input.name }}' => {{ input.default_code }},
{% endfor %}
] + parent::defaultConfiguration();

}
}

/**
* {@inheritdoc}
Expand All @@ -89,12 +87,12 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{% for input in inputs %}
$form['{{ input.name }}'] = [
'#type' => '{{ input.type }}',
'#title' => $this->t('{{ input.label }}'),
'#description' => $this->t('{{ input.description }}'),
'#title' => $this->t('{{ input.label|escape }}'),
'#description' => $this->t('{{ input.description|escape }}'),
{% if input.options|length %}
'#options' => {{ input.options }},
{% endif %}
'#default_value' => $this->configuration['{{ input.name }}'],
'#default_value' => $this->configuration['{{ input.name }}'],
{% if input.maxlength|length %}
'#maxlength' => {{ input.maxlength }},
{% endif %}
Expand Down

0 comments on commit 13c437b

Please sign in to comment.