You are here

public static function EditorNote::preCreate in Editor Notes 8

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/EditorNote.php, line 41

Class

EditorNote
Defines the EditorNote entity.

Namespace

Drupal\editor_note\Entity

Code

public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
  parent::preCreate($storage_controller, $values);
  $values += [
    'uid' => \Drupal::currentUser()
      ->id(),
  ];
}