entity_reference_uuid-8.x-1.x-dev/tests/modules/entity_reference_uuid_test/src/Form/TestEntityTwoForm.php

tests/modules/entity_reference_uuid_test/src/Form/TestEntityTwoForm.php
<?php

namespace Drupal\entity_reference_uuid_test\Form;

use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Form\FormStateInterface;

/**
 * Form controller for Test entity one edit forms.
 *
 * @ingroup entity_reference_uuid_test
 */
class TestEntityTwoForm extends ContentEntityForm {

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

    $status = parent::save($form, $form_state);

    switch ($status) {
      case SAVED_NEW:
        $this->messenger()->addStatus($this->t('Created the %label Test entity two.', [
          '%label' => $entity->label(),
        ]));
        break;

      default:
        $this->messenger()->addStatus($this->t('Saved the %label Test entity two.', [
          '%label' => $entity->label(),
        ]));
    }
    $form_state->setRedirect('entity.test_entity_two.canonical', ['test_entity_two' => $entity->id()]);

    return $status;
  }

}

Главная | Обратная связь

drupal hosting | друпал хостинг | it patrol .inc