abstract class EdgeEntityBase in Apigee Edge 8
Base class for Apigee Edge entities in Drupal.
Hierarchy
- class \Drupal\Core\Entity\EntityBase implements EntityInterface uses RefinableCacheableDependencyTrait, DependencySerializationTrait
- class \Drupal\apigee_edge\Entity\EdgeEntityBase implements EdgeEntityInterface
Expanded class hierarchy of EdgeEntityBase
File
- src/
Entity/ EdgeEntityBase.php, line 31
Namespace
Drupal\apigee_edge\EntityView source
abstract class EdgeEntityBase extends EntityBase implements EdgeEntityInterface {
/**
* The decorated SDK entity.
*
* @var \Apigee\Edge\Entity\EntityInterface
*/
protected $decorated;
/**
* EdgeEntityBase constructor.
*
* @param array $values
* An array of values to set, keyed by property name.
* @param null|string $entity_type
* Type of the entity.
* @param \Apigee\Edge\Entity\EntityInterface|null $decorated
* The SDK entity that this Drupal entity decorates.
*
* @throws \ReflectionException
*/
public function __construct(array $values, string $entity_type, ?EntityInterface $decorated = NULL) {
parent::__construct([], $entity_type);
if ($decorated) {
$this->decorated = $decorated;
}
else {
$rc = new \ReflectionClass($this
->decoratedClass());
if (!$rc
->implementsInterface(EntityInterface::class)) {
throw new InvalidArgumentException(sprintf('"%s" interface must be implemented by the decorated class.', $rc
->getName()));
}
// Get rid of useless but also problematic null values.
// (SDK entity classes do not like them.)
$values = array_filter($values, function ($value) {
return !is_null($value);
});
$this->decorated = $rc
->newInstance($values);
}
}
/**
* The FQCN of the decorated class from the PHP API Client.
*
* @return string
* FQCN of the entity class.
*/
protected static abstract function decoratedClass() : string;
/**
* {@inheritdoc}
*
* We have to override this to make it compatible with the SDK's
* entity interface that enforces the return type.
*/
public function id() : ?string {
return $this
->drupalEntityId();
}
/**
* Return the entity id used in Drupal.
*
* @return null|string
* Null if the entity is new.
*/
protected abstract function drupalEntityId() : ?string;
/**
* {@inheritdoc}
*/
public static function uniqueIdProperties() : array {
return [
static::idProperty(),
];
}
/**
* {@inheritdoc}
*/
public function uniqueIds() : array {
$ids = [];
$ro = new \ReflectionObject($this);
foreach (static::uniqueIdProperties() as $property) {
$getter = 'get' . ucfirst($property);
$ids[] = $ro
->getMethod($getter)
->invoke($this);
}
return $ids;
}
/**
* Creates a Drupal entity from an SDK Entity.
*
* @param \Apigee\Edge\Entity\EntityInterface $entity
* An SDK entity.
*
* @return \Drupal\apigee_edge\Entity\EdgeEntityInterface
* The Drupal entity that decorates the SDK entity.
*/
public static function createFrom(EntityInterface $entity) : EdgeEntityInterface {
return new static([], NULL, $entity);
}
/**
* {@inheritdoc}
*/
public function decorated() : EntityInterface {
return $this->decorated;
}
/**
* {@inheritdoc}
*/
public function label() {
$label = parent::label();
if ($label === NULL) {
if (in_array(DisplayNamePropertyInterface::class, class_implements($this)) && !empty($this
->getDisplayName())) {
$label = $this
->getDisplayName();
}
else {
$label = $this
->id();
}
}
return $label;
}
/**
* {@inheritdoc}
*/
public function isTranslatable() {
return FALSE;
}
/**
* {@inheritdoc}
*/
public function getTranslation($langcode) {
if ($langcode == $this
->language()
->getId()) {
return $this;
}
throw new \InvalidArgumentException("Invalid translation language ({$langcode}) specified.");
}
/**
* {@inheritdoc}
*/
public function hasTranslation($langcode) {
return $langcode == $this
->language()
->getId();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CacheableDependencyTrait:: |
protected | property | Cache contexts. | |
CacheableDependencyTrait:: |
protected | property | Cache max-age. | |
CacheableDependencyTrait:: |
protected | property | Cache tags. | |
CacheableDependencyTrait:: |
protected | function | Sets cacheability; useful for value object constructors. | |
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | Aliased as: traitSleep | 1 |
DependencySerializationTrait:: |
public | function | 2 | |
EdgeEntityBase:: |
protected | property | The decorated SDK entity. | 2 |
EdgeEntityBase:: |
public static | function |
Creates a Drupal entity from an SDK Entity. Overrides EdgeEntityInterface:: |
|
EdgeEntityBase:: |
public | function |
Returns the decorated SDK entity. Overrides EdgeEntityInterface:: |
2 |
EdgeEntityBase:: |
abstract protected static | function | The FQCN of the decorated class from the PHP API Client. | 5 |
EdgeEntityBase:: |
abstract protected | function | Return the entity id used in Drupal. | 4 |
EdgeEntityBase:: |
public | function | ||
EdgeEntityBase:: |
public | function | ||
EdgeEntityBase:: |
public | function |
We have to override this to make it compatible with the SDK's
entity interface that enforces the return type. Overrides EntityBase:: |
5 |
EdgeEntityBase:: |
public | function | ||
EdgeEntityBase:: |
public | function |
Gets the label of the entity. Overrides EntityBase:: |
2 |
EdgeEntityBase:: |
public static | function |
Returns all unique ids how an entity can be referenced in Apigee Edge. Overrides EdgeEntityInterface:: |
2 |
EdgeEntityBase:: |
public | function |
List of unique ids how an entity can be referenced in Apigee Edge. Overrides EdgeEntityInterface:: |
|
EdgeEntityBase:: |
public | function |
EdgeEntityBase constructor. Overrides EntityBase:: |
3 |
EntityBase:: |
protected | property | Boolean indicating whether the entity should be forced to be new. | |
EntityBase:: |
protected | property | The entity type. | |
EntityBase:: |
protected | property | A typed data object wrapping this entity. | |
EntityBase:: |
public | function |
Checks data value access. Overrides AccessibleInterface:: |
1 |
EntityBase:: |
public | function |
Gets the bundle of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public static | function |
Constructs a new entity object, without permanently saving it. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Creates a duplicate of the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Deletes an entity permanently. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Enforces an entity to be new. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | Gets the entity manager. | |
EntityBase:: |
protected | function | Gets the entity type bundle info service. | |
EntityBase:: |
protected | function | Gets the entity type manager. | |
EntityBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The maximum age for which this object may be cached. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
The cache tags associated with this object. Overrides CacheableDependencyTrait:: |
|
EntityBase:: |
public | function |
Returns the cache tags that should be used to invalidate caches. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the key that is used to store configuration dependencies. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the configuration dependency name. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the configuration target identifier for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets the entity type definition. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the ID of the type of the entity. Overrides EntityInterface:: |
|
EntityBase:: |
protected | function | The list cache tags to invalidate for this entity. | |
EntityBase:: |
public | function |
Gets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets a typed data object for this entity object. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Indicates if a link template exists for a given key. Overrides EntityInterface:: |
|
EntityBase:: |
protected static | function | Invalidates an entity's cache tags upon delete. | 1 |
EntityBase:: |
protected | function | Invalidates an entity's cache tags upon save. | 1 |
EntityBase:: |
public | function |
Determines whether the entity is new. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the language of the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the language manager. | |
EntityBase:: |
public | function |
Deprecated way of generating a link to the entity. See toLink(). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array link templates. | 1 |
EntityBase:: |
public static | function |
Loads an entity. Overrides EntityInterface:: |
|
EntityBase:: |
public static | function |
Loads one or more entities. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Acts on a created entity before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public static | function |
Acts on deleted entities before the delete hook is invoked. Overrides EntityInterface:: |
16 |
EntityBase:: |
public static | function |
Acts on loaded entities. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Acts on a saved entity before the insert or update hook is invoked. Overrides EntityInterface:: |
14 |
EntityBase:: |
public static | function |
Changes the values of an entity before it is created. Overrides EntityInterface:: |
5 |
EntityBase:: |
public static | function |
Acts on entities before they are deleted and before hooks are invoked. Overrides EntityInterface:: |
4 |
EntityBase:: |
public | function |
Acts on an entity before the presave hook is invoked. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of entities referenced by this entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Saves an entity permanently. Overrides EntityInterface:: |
3 |
EntityBase:: |
public | function |
Sets the original ID. Overrides EntityInterface:: |
1 |
EntityBase:: |
public | function |
Gets an array of all property values. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Generates the HTML for a link to this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets a list of URI relationships supported by this entity. Overrides EntityInterface:: |
|
EntityBase:: |
public | function |
Gets the public URL for this entity. Overrides EntityInterface:: |
2 |
EntityBase:: |
public | function |
Gets the URL object for the entity. Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets an array of placeholders for this entity. | 2 |
EntityBase:: |
public | function |
Gets the entity UUID (Universally Unique Identifier). Overrides EntityInterface:: |
1 |
EntityBase:: |
protected | function | Gets the UUID generator. | |
EntityBase:: |
public | function | 2 | |
RefinableCacheableDependencyTrait:: |
public | function | 1 | |
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function | ||
RefinableCacheableDependencyTrait:: |
public | function |