You are here

class AvatarKitAvatarServiceDiscovery in Avatar Kit 8.2

Avatar Kit library service discovery.

Hierarchy

Expanded class hierarchy of AvatarKitAvatarServiceDiscovery

1 string reference to 'AvatarKitAvatarServiceDiscovery'
avatars.services.yml in ./avatars.services.yml
avatars.services.yml
1 service uses AvatarKitAvatarServiceDiscovery
avatars.avatar_kit.discovery.services in ./avatars.services.yml
Drupal\avatars\AvatarKitAvatarServiceDiscovery

File

src/AvatarKitAvatarServiceDiscovery.php, line 15

Namespace

Drupal\avatars
View source
class AvatarKitAvatarServiceDiscovery extends AvatarServiceDiscovery {
  use UseCacheBackendTrait;

  /**
   * The class loader.
   *
   * @var \Composer\Autoload\ClassLoader
   */
  protected $classLoader;

  /**
   * Backend for caching discovery results.
   *
   * @var \Drupal\Core\Cache\CacheBackendInterface
   */
  protected $cacheBackend;

  /**
   * Constructs a new AvatarKitAvatarServiceDiscovery object.
   *
   * @param object $class_loader
   *   The class loader.
   * @param \Drupal\Core\Cache\CacheBackendInterface $cache_backend
   *   Backend for caching discovery results.
   */
  public function __construct($class_loader, CacheBackendInterface $cache_backend) {
    $this->subdir = 'AvatarKit/AvatarServices/';
    $this->serviceInterface = AvatarServiceInterface::class;
    $this->annotationClass = AvatarService::class;
    $this->cacheBackend = $cache_backend;
    $cache_key = 'avatars_ak_service_annotations';
    $annotations = $this
      ->cacheGet($cache_key)->data ?? NULL;
    if (!isset($annotations)) {
      $root_namespaces = $class_loader
        ->getPrefixesPsr4();
      $classes = $this
        ->discoverClasses($root_namespaces);
      $annotations = $this
        ->discoverAnnotations($classes);
      $this
        ->cacheSet($cache_key, $annotations, Cache::PERMANENT);
    }
    $this->annotations = $annotations;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AvatarKitAvatarServiceDiscovery::$cacheBackend protected property Backend for caching discovery results. Overrides UseCacheBackendTrait::$cacheBackend
AvatarKitAvatarServiceDiscovery::$classLoader protected property The class loader.
AvatarKitAvatarServiceDiscovery::__construct public function Constructs a new AvatarKitAvatarServiceDiscovery object.
UseCacheBackendTrait::$useCaches protected property Flag whether caches should be used or skipped.
UseCacheBackendTrait::cacheGet protected function Fetches from the cache backend, respecting the use caches flag. 1
UseCacheBackendTrait::cacheSet protected function Stores data in the persistent cache, respecting the use caches flag.