trait EntityOwnerTrait in Commerce Core 8.2
Provides a trait for Commerce entities that have an owner.
Hierarchy
- trait \Drupal\commerce\EntityOwnerTrait uses EntityOwnerTrait
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\commerceView 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
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EntityOwnerTrait:: |
public static | function | Default value callback for 'owner' base field. | 1 |
EntityOwnerTrait:: |
public | function |
Overrides EntityOwnerTrait:: |
|
EntityOwnerTrait:: |
public | function | ||
EntityOwnerTrait:: |
public static | function | Returns an array of base field definitions for entity owners. | |
EntityOwnerTrait:: |
public | function | ||
EntityOwnerTrait:: |
public | function |