You are here

public function AvatarKitLocalCache::getLocalCache in Avatar Kit 8.2

Determines if a avatar cache exists.

Parameters

string $service_id: An avatar service ID.

\Drupal\avatars\EntityAvatarIdentifierInterface $identifier: An entity avatar identifier.

Return value

\Drupal\avatars\Entity\AvatarCacheInterface|null An avatar cache entity, or NULL if it does not exist given parameters.

Overrides AvatarKitLocalCacheInterface::getLocalCache

File

src/AvatarKitLocalCache.php, line 63

Class

AvatarKitLocalCache
Cache remote files locally into file entities.

Namespace

Drupal\avatars

Code

public function getLocalCache(string $service_id, EntityAvatarIdentifierInterface $identifier) : ?AvatarCacheInterface {
  $hashed = $identifier
    ->getHashed();
  $ids = $this->avatarCacheStorage
    ->getQuery()
    ->condition('avatar_service', $service_id)
    ->condition('identifier', $hashed)
    ->execute();
  if ($ids) {
    $id = reset($ids);
    return $this->avatarCacheStorage
      ->load($id);
  }
  return NULL;
}