You are here

public static function MediaGallery::preCreate in Media Gallery 8

When a new media gallery entity is created, set the uid entity reference to the current user as the creator of the entity.

Overrides EntityBase::preCreate

File

src/Entity/MediaGallery.php, line 66

Class

MediaGallery
Defines the media gallery entity class.

Namespace

Drupal\media_gallery\Entity

Code

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