You are here

public function AppByOwnerController::load in Apigee Edge 8

Overrides CachedEntityCrudOperationsControllerTrait::load

File

src/Entity/Controller/AppByOwnerController.php, line 137

Class

AppByOwnerController
Base class for developer- and company app controller services in Drupal.

Namespace

Drupal\apigee_edge\Entity\Controller

Code

public function load(string $entity_id) : EntityInterface {

  // Check whether the $entityId is an app name and it can
  // be found in app owner's cache.
  $entity = $this->appCacheByOwner
    ->getEntity($entity_id);

  // So is it an app id (UUID) then?
  if ($entity === NULL) {
    $entity = $this->appCache
      ->getEntity($entity_id);
  }

  // The app has not found in caches so we have to load it from Apigee
  // Edge.
  if ($entity === NULL) {
    $entity = $this
      ->decorated()
      ->load($entity_id);

    // Saving it to app owner's cache ensures that app cache and app id
    // cache gets updated as well.
    $this->appCacheByOwner
      ->saveEntities([
      $entity,
    ]);
  }
  return $entity;
}