Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 22 commits into from
Jun 24, 2019
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
292d0c2
[update:execute] Fixed update table
hjuarez20 May 23, 2019
9f85a38
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 23, 2019
bd837ce
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 24, 2019
522c7ca
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 27, 2019
ce54425
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 28, 2019
a95b7e6
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 29, 2019
ddf7739
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 29, 2019
2726f79
Revert "Merge remote-tracking branch 'upstream/master'"
hjuarez20 May 29, 2019
d36f4ad
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 31, 2019
0ef770c
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 31, 2019
deff1f3
Merge remote-tracking branch 'upstream/master'
hjuarez20 May 31, 2019
e3a4bc7
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 3, 2019
31c8bd7
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 5, 2019
c1f461e
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 10, 2019
cb93e78
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 12, 2019
fcd4a61
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 17, 2019
8ccdb68
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 17, 2019
0fdd609
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 18, 2019
df5a840
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 18, 2019
c9c11ae
Merge remote-tracking branches 'origin' and 'upstream/master'
hjuarez20 Jun 22, 2019
bf69146
Merge remote-tracking branch 'upstream/master'
hjuarez20 Jun 24, 2019
eb6d1b6
[generate:plugin:block] Added code standard
hjuarez20 Jun 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions templates/module/src/Plugin/Block/block.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand All @@ -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}
*/
Expand All @@ -65,6 +72,7 @@ class {{class_name}} extends BlockBase {% if services is not empty %}implements
{{ serviceClassInjection(services) }}
);
}

{% endif %}
{% endblock %}
{% block class_methods %}
Expand All @@ -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();
}
Expand All @@ -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 }},
Expand Down Expand Up @@ -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 %}
Expand Down