You are here

public function EntityOwnerTrait::setOwner in Drupal 8

Same name and namespace in other branches
  1. 9 core/modules/user/src/EntityOwnerTrait.php \Drupal\user\EntityOwnerTrait::setOwner()

File

core/modules/user/src/EntityOwnerTrait.php, line 73

Class

EntityOwnerTrait
Provides a trait for entities that have an owner.

Namespace

Drupal\user

Code

public function setOwner(UserInterface $account) {
  $key = $this
    ->getEntityType()
    ->getKey('owner');
  $this
    ->set($key, $account);
  return $this;
}