<commit_before>{% extends "base/class.php.twig" %}

{% block file_path %}
\Drupal\{{module}}\Plugin\Block\{{class_name}}.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module}}\Plugin\Block;
{% endblock %}

{% block use_class %}
use Drupal\Core\Block\BlockBase;
{% if inputs %}
use Drupal\Core\Form\FormStateInterface;
{% endif %}
{% if services is not empty %}
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endblock %}

{% block use_class_services %}
{% endblock %}

{% block class_declaration %}
/**
 * Provides a '{{class_name}}' block.
 *
 * @Block(
 *  id = "{{plugin_id}}",
 *  admin_label = @Translation("{{label}}"),
 * )
 */
class {{class_name}} extends BlockBase {% if services is not empty %}implements ContainerFactoryPluginInterface {% endif %}{% endblock %}

{% block class_create %}
{% if services is not empty %}
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = new static($configuration, $plugin_id, $plugin_definition);
{{ serviceClassInjectionNoOverride(services) }}
    return $instance;
  }

{% endif %}
{% endblock %}
{% block class_methods %}
{% if inputs %}
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
{% for input in inputs %}
{% if input.default_value is defined and input.default_value|length %}
      '{{ input.name }}' => {{ input.default_value }},
{% endif %}
{% endfor %}
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
{% for input in inputs %}
    $form['{{ input.name }}'] = [
      '#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 }}'),
{% endif %}
{% if input.options is defined and input.options|length %}
      '#options' => {{ input.options }},
{% endif %}
      '#default_value' => $this->configuration['{{ input.name }}'],
{% if input.maxlength is defined and input.maxlength|length %}
      '#maxlength' => {{ input.maxlength }},
{% endif %}
{% if input.size is defined and input.size|length %}
      '#size' => {{ input.size }},
{% endif %}
{% if input.weight is defined and input.weight|length %}
      '#weight' => '{{ input.weight }}',
{% endif %}
    ];
{% endfor %}

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
{% for input in inputs %}
    $this->configuration['{{ input.name }}'] = $form_state->getValue('{{ input.name }}'){% if input.type == 'text_format' %}['value']{% endif %};
{% endfor %}
  }

{% endif %}
  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];
{% if twig_template is defined %}
    $build['#theme'] = '{{ plugin_id }}';
{% endif %}
{% for input in inputs %}
{% if twig_template is defined %}
    $build['#conten'][] = $this->configuration['{{ input.name }}'];
{% else %}
    $build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}'] . '</p>';
{% endif %}
{% else %}
     $build['{{plugin_id}}']['#markup'] = 'Implement {{class_name}}.';
{% endfor %}

    return $build;
  }
{% endblock %}<commit_msg>Output from generate:plugin:block fixed. (#4218)<commit_after>{% extends "base/class.php.twig" %}

{% block file_path %}
\Drupal\{{module}}\Plugin\Block\{{class_name}}.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{module}}\Plugin\Block;
{% endblock %}

{% block use_class %}
use Drupal\Core\Block\BlockBase;
{% if inputs %}
use Drupal\Core\Form\FormStateInterface;
{% endif %}
{% if services is not empty %}
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
{% endif %}
{% endblock %}

{% block use_class_services %}
{% endblock %}

{% block class_declaration %}
/**
 * Provides a '{{class_name}}' block.
 *
 * @Block(
 *  id = "{{plugin_id}}",
 *  admin_label = @Translation("{{label}}"),
 * )
 */
class {{class_name}} extends BlockBase {% if services is not empty %}implements ContainerFactoryPluginInterface {% endif %}{% endblock %}

{% block class_create %}
{% if services is not empty %}
  /**
   * {@inheritdoc}
   */
  public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
    $instance = new static($configuration, $plugin_id, $plugin_definition);
{{ serviceClassInjectionNoOverride(services) }}
    return $instance;
  }

{% endif %}
{% endblock %}
{% block class_methods %}
{% if inputs %}
  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
{% for input in inputs %}
{% if input.default_value is defined and input.default_value|length %}
      '{{ input.name }}' => $this->('{{ input.default_value }}'),
{% endif %}
{% endfor %}
    ] + parent::defaultConfiguration();
  }

  /**
   * {@inheritdoc}
   */
  public function blockForm($form, FormStateInterface $form_state) {
{% for input in inputs %}
    $form['{{ input.name }}'] = [
      '#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 }}'),
{% endif %}
{% if input.options is defined and input.options|length %}
      '#options' => {{ input.options }},
{% endif %}
      '#default_value' => $this->configuration['{{ input.name }}'],
{% if input.maxlength is defined and input.maxlength|length %}
      '#maxlength' => {{ input.maxlength }},
{% endif %}
{% if input.size is defined and input.size|length %}
      '#size' => {{ input.size }},
{% endif %}
{% if input.weight is defined and input.weight|length %}
      '#weight' => '{{ input.weight }}',
{% endif %}
    ];
{% endfor %}

    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public function blockSubmit($form, FormStateInterface $form_state) {
{% for input in inputs %}
    $this->configuration['{{ input.name }}'] = $form_state->getValue('{{ input.name }}'){% if input.type == 'text_format' %}['value']{% endif %};
{% endfor %}
  }

{% endif %}
  /**
   * {@inheritdoc}
   */
  public function build() {
    $build = [];
{% if twig_template is defined %}
    $build['#theme'] = '{{ plugin_id }}';
{% endif %}
{% for input in inputs %}
{% if twig_template is defined %}
    $build['#content'][] = $this->configuration['{{ input.name }}'];
{% else %}
    $build['{{plugin_id}}_{{ input.name }}']['#markup'] = '<p>' . $this->configuration['{{ input.name }}'] . '</p>';
{% endif %}
{% else %}
     $build['{{plugin_id}}']['#markup'] = 'Implement {{class_name}}.';
{% endfor %}

    return $build;
  }
{% endblock %}
{'fraction_non_alphanumeric': 0.20754716981132076, 'fraction_numerical': 0.0005761198329252485, 'mean_word_length': 3.9423487544483984, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 40, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '818959', 'n_tokens_mistral': 2365, 'n_tokens_neox': 2146, 'n_words': 491}