From 032f80e3dc93f09c4a14cb7611866767ee71491b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Harold=20Ju=C3=A1rez?= Date: Mon, 24 Jun 2019 15:08:41 -0600 Subject: [PATCH] [generate:plugin:block] Added code standard (#4099) * [update:execute] Fixed update table * Revert "Merge remote-tracking branch 'upstream/master'" This reverts commit ddf77395b32e35f259e9b1503eedb71b71c52604, reversing changes made to a95b7e60be2b2cd53d5371f2cc2c0d976e1c1c19. * [generate:plugin:block] Added code standard --- .../module/src/Plugin/Block/block.php.twig | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/templates/module/src/Plugin/Block/block.php.twig b/templates/module/src/Plugin/Block/block.php.twig index 261ee3955..890596d3b 100644 --- a/templates/module/src/Plugin/Block/block.php.twig +++ b/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'] = '

' . $this->configuration['{{ input.name }}']. '

'; + $build['{{plugin_id}}_{{ input.name }}']['#markup'] = '

' . $this->configuration['{{ input.name }}'] . '

'; {% else %} $build['{{plugin_id}}']['#markup'] = 'Implement {{class_name}}.'; {% endfor %}