public static function EntityTestWithOwner::preCreate in Group 8
Same name and namespace in other branches
- 2.0.x tests/modules/group_test_plugin/src/Entity/EntityTestWithOwner.php \Drupal\group_test_plugin\Entity\EntityTestWithOwner::preCreate()
Changes the values of an entity before it is created.
Load defaults for example.
Parameters
\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.
mixed[] $values: An array of values to set, keyed by property name. If the entity type has bundles the bundle key has to be specified.
Overrides EntityBase::preCreate
File
- tests/
modules/ group_test_plugin/ src/ Entity/ EntityTestWithOwner.php, line 42
Class
- EntityTestWithOwner
- Defines the test entity with owner class.
Namespace
Drupal\group_test_plugin\EntityCode
public static function preCreate(EntityStorageInterface $storage, array &$values) {
parent::preCreate($storage, $values);
if (empty($values['type'])) {
$values['type'] = $storage
->getEntityTypeId();
}
}