You are here

public static function PrivateMessage::preCreate in Private Message 8

Same name and namespace in other branches
  1. 8.2 src/Entity/PrivateMessage.php \Drupal\private_message\Entity\PrivateMessage::preCreate()

When a new private message is created, set the owner entity reference to the current user as the creator of the instance.

Overrides EntityBase::preCreate

File

src/Entity/PrivateMessage.php, line 47

Class

PrivateMessage
Thee Private Message entity definition.

Namespace

Drupal\private_message\Entity

Code

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