You are here

trait EntityOwnerTrait in Commerce Core 8.2

Provides a trait for Commerce entities that have an owner.

Hierarchy

5 files declare their use of EntityOwnerTrait
PaymentMethod.php in modules/payment/src/Entity/PaymentMethod.php
Product.php in modules/product/src/Entity/Product.php
ProductVariation.php in modules/product/src/Entity/ProductVariation.php
Promotion.php in modules/promotion/src/Entity/Promotion.php
Store.php in modules/store/src/Entity/Store.php

File

src/EntityOwnerTrait.php, line 11

Namespace

Drupal\commerce
View source
trait EntityOwnerTrait {
  use CoreEntityOwnerTrait;

  /**
   * {@inheritdoc}
   */
  public function getOwner() {
    $key = $this
      ->getEntityType()
      ->getKey('owner');
    $owner = $this
      ->get($key)->entity;

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

}

Members

Namesort descending Modifiers Type Description Overrides
EntityOwnerTrait::getDefaultEntityOwner public static function Default value callback for 'owner' base field. 1
EntityOwnerTrait::getOwner public function Overrides EntityOwnerTrait::getOwner
EntityOwnerTrait::getOwnerId public function
EntityOwnerTrait::ownerBaseFieldDefinitions public static function Returns an array of base field definitions for entity owners.
EntityOwnerTrait::setOwner public function
EntityOwnerTrait::setOwnerId public function