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

{% block file_path %}
Drupal\{{ module }}\Form\{{ entity_class }}Form.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{ module }}\Form;
{% endblock %}

{% block use_class %}
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
{% endblock %}

{% block class_declaration %}
class {{ entity_class }}Form extends EntityForm
{% endblock %}

{% block class_methods %}
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    ${{ entity_name }} = $this->entity;
    $form['label'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Label'),
      '#maxlength' => 255,
      '#default_value' => ${{ entity_name }}->label(),
      '#description' => $this->t("Label for the {{ entity_class }}."),
      '#required' => TRUE,
    );

    $form['id'] = array(
      '#type' => 'machine_name',
      '#default_value' => ${{ entity_name }}->id(),
      '#machine_name' => array(
        'exists' => '{{ entity_name }}_load',
      ),
      '#disabled' => !${{ entity_name }}->isNew(),
    );

    // You will need additional form elements for your custom properties.

    return $form;
  }

  /**
  * {@inheritdoc}
  */
  public function save(array $form, FormStateInterface $form_state) {
    ${{ entity_name }} = $this->entity;
    $status = ${{ entity_name }}->save();

    if ($status) {
      drupal_set_message($this->t('Saved the %label {{ entity_class }}.', array(
        '%label' => ${{ entity_name }}->label(),
      )));
    }
    else {
      drupal_set_message($this->t('The %label {{ entity_class }} was not saved.', array(
        '%label' => ${{ entity_name }}->label(),
      )));
    }
    $form_state['redirect'] = 'admin/config/system/{{ entity_name }}';
  }
{% endblock %}<commit_msg>Use method setRedirect on form_state object<commit_after>{% extends "base/class.php.twig" %}

{% block file_path %}
Drupal\{{ module }}\Form\{{ entity_class }}Form.
{% endblock %}

{% block namespace_class %}
namespace Drupal\{{ module }}\Form;
{% endblock %}

{% block use_class %}
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
{% endblock %}

{% block class_declaration %}
class {{ entity_class }}Form extends EntityForm
{% endblock %}

{% block class_methods %}
  /**
   * {@inheritdoc}
   */
  public function form(array $form, FormStateInterface $form_state) {
    $form = parent::form($form, $form_state);

    ${{ entity_name }} = $this->entity;
    $form['label'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Label'),
      '#maxlength' => 255,
      '#default_value' => ${{ entity_name }}->label(),
      '#description' => $this->t("Label for the {{ entity_class }}."),
      '#required' => TRUE,
    );

    $form['id'] = array(
      '#type' => 'machine_name',
      '#default_value' => ${{ entity_name }}->id(),
      '#machine_name' => array(
        'exists' => '{{ entity_name }}_load',
      ),
      '#disabled' => !${{ entity_name }}->isNew(),
    );

    // You will need additional form elements for your custom properties.

    return $form;
  }

  /**
  * {@inheritdoc}
  */
  public function save(array $form, FormStateInterface $form_state) {
    ${{ entity_name }} = $this->entity;
    $status = ${{ entity_name }}->save();

    if ($status) {
      drupal_set_message($this->t('Saved the %label {{ entity_class }}.', array(
        '%label' => ${{ entity_name }}->label(),
      )));
    }
    else {
      drupal_set_message($this->t('The %label {{ entity_class }} was not saved.', array(
        '%label' => ${{ entity_name }}->label(),
      )));
    }
    $form_state->setRedirect('{{ entity_name }}.list');
  }
{% endblock %}
{'fraction_non_alphanumeric': 0.20484411234217986, 'fraction_numerical': 0.001545993300695697, 'mean_word_length': 3.205850487540628, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 54, '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': '6033057', 'n_tokens_mistral': 1292, 'n_tokens_neox': 1251, 'n_words': 267}