public static function PrivateMessage::preCreate in Private Message 8.2
Same name and namespace in other branches
- 8 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\EntityCode
public static function preCreate(EntityStorageInterface $storage_controller, array &$values) {
parent::preCreate($storage_controller, $values);
$values += [
'owner' => \Drupal::currentUser()
->id(),
];
}