You are here

public static function PushNotification::preCreate in Push Notifications 8

When a new entity instance is added, set the user_uid entity reference to the current user as the creator of the instance.

Overrides EntityBase::preCreate

File

src/Entity/PushNotification.php, line 65
Contains Drupal\push_notifications\Entity\PushNotification.

Class

PushNotification
Defines the push_notification entity.

Namespace

Drupal\push_notifications\Entity

Code

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