You are here

public function EntityOwnerTrait::getOwner in Commerce Core 8.2

Overrides EntityOwnerTrait::getOwner

File

src/EntityOwnerTrait.php, line 18

Class

EntityOwnerTrait
Provides a trait for Commerce entities that have an owner.

Namespace

Drupal\commerce

Code

public function getOwner() {
  $key = $this
    ->getEntityType()
    ->getKey('owner');
  $owner = $this
    ->get($key)->entity;

  // Handle deleted customers.
  if (!$owner) {
    $owner = User::getAnonymousUser();
  }
  return $owner;
}