You are here

protected function AppStorage::getFromStorage in Apigee Edge 8

Gets entities from the storage.

Parameters

array|null $ids: If not empty, return entities that match these IDs. Return all entities when NULL.

Return value

\Drupal\Core\Entity\EntityInterface[] Array of entities from the storage.

Throws

\Drupal\Core\Entity\EntityStorageException

Overrides EdgeEntityStorageBase::getFromStorage

File

src/Entity/Storage/AppStorage.php, line 141

Class

AppStorage
Base entity storage class for developer and team (company) app entities.

Namespace

Drupal\apigee_edge\Entity\Storage

Code

protected function getFromStorage(array $ids = NULL) {

  // Try to load entities from the entity controller's static cache.
  if (!empty($ids)) {

    // If $ids are developer app ids (UUIDs) let's check whether all (SDK)
    // entities can be served from the shared app (controller) cache.
    // When AppQueryBase::getFromStorage() tries to reduce the API calls by
    // doing something smart it could happen that entity storage's static
    // cache has not warmed up yet but the shared app cache did.
    // @see \Drupal\apigee_edge\Entity\Query\AppQueryBase::getFromStorage()
    if ($this->appController instanceof EntityCacheAwareControllerInterface) {
      $cached_entities = $this->appController
        ->entityCache()
        ->getEntities($ids);
      if (count($cached_entities) === count($ids)) {
        return $this
          ->processLoadedEntities($ids, $cached_entities);
      }
    }
  }
  return parent::getFromStorage($ids);
}