public static function MaestroEntityIdentifiers::preCreate in Maestro 3.x
Same name and namespace in other branches
- 8.2 src/Entity/MaestroEntityIdentifiers.php \Drupal\maestro\Entity\MaestroEntityIdentifiers::preCreate()
When a new entity instance is added, set the user_id entity reference to the current user as the creator of the instance.
Overrides EntityBase::preCreate
File
- src/
Entity/ MaestroEntityIdentifiers.php, line 56
Class
- MaestroEntityIdentifiers
- Defines the MaestroEntityIdentifiers entity.
Namespace
Drupal\maestro\EntityCode
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'user_id' => \Drupal::currentUser()
->id(),
];
}