You are here

protected function EntityTestForm::prepareEntity in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/entity_test/src/EntityTestForm.php \Drupal\entity_test\EntityTestForm::prepareEntity()

Prepares the entity object before the form is built first.

Overrides EntityForm::prepareEntity

File

core/modules/system/tests/modules/entity_test/src/EntityTestForm.php, line 21
Contains \Drupal\entity_test\EntityTestForm.

Class

EntityTestForm
Form controller for the test entity edit forms.

Namespace

Drupal\entity_test

Code

protected function prepareEntity() {
  if (empty($this->entity->name->value)) {

    // Assign a random name to new EntityTest entities, to avoid repetition in
    // tests.
    $random = new Random();
    $this->entity->name->value = $random
      ->name();
  }
}