You are here

public function CachedAttributesAwareEntityControllerTrait::getAttribute in Apigee Edge 8

File

src/Entity/Controller/CachedAttributesAwareEntityControllerTrait.php, line 64

Class

CachedAttributesAwareEntityControllerTrait
Helper trait for those entity controllers that supports attribute CRUDL.

Namespace

Drupal\apigee_edge\Entity\Controller

Code

public function getAttribute(string $entity_id, string $name) : string {
  $entity = $this
    ->entityCache()
    ->getEntity($entity_id);

  /** @var \Apigee\Edge\Entity\Property\AttributesPropertyInterface $entity */
  if ($entity) {
    return $entity
      ->getAttributeValue($name);
  }
  return $this
    ->decorated()
    ->getAttribute($entity_id, $name);
}