function EntityTest::preCreate

Same name in other branches
  1. 8.9.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php \Drupal\entity_test\Entity\EntityTest::preCreate()
  2. 10 core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php \Drupal\entity_test\Entity\EntityTest::preCreate()
  3. 11.x core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php \Drupal\entity_test\Entity\EntityTest::preCreate()

Overrides EntityBase::preCreate

1 call to EntityTest::preCreate()
EntityTestBundleClass::preCreate in core/modules/system/tests/modules/entity_test_bundle_class/src/Entity/EntityTestBundleClass.php
Changes the values of an entity before it is created.
1 method overrides EntityTest::preCreate()
EntityTestBundleClass::preCreate in core/modules/system/tests/modules/entity_test_bundle_class/src/Entity/EntityTestBundleClass.php
Changes the values of an entity before it is created.

File

core/modules/system/tests/modules/entity_test/src/Entity/EntityTest.php, line 59

Class

EntityTest
Defines the test entity class.

Namespace

Drupal\entity_test\Entity

Code

public static function preCreate(EntityStorageInterface $storage, array &$values) {
    parent::preCreate($storage, $values);
    if (empty($values['type'])) {
        $values['type'] = $storage->getEntityTypeId();
    }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.