You are here

public static function MaestroProductionAssignments::preCreate in Maestro 3.x

Same name and namespace in other branches
  1. 8.2 src/Entity/MaestroProductionAssignments.php \Drupal\maestro\Entity\MaestroProductionAssignments::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/MaestroProductionAssignments.php, line 59

Class

MaestroProductionAssignments
Defines the MaestroProductionAssignments entity.

Namespace

Drupal\maestro\Entity

Code

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