You are here

class CachedClassMapGenerator in X Autoload 7.4

Same name and namespace in other branches
  1. 7.5 src/Discovery/CachedClassMapGenerator.php \Drupal\xautoload\Discovery\CachedClassMapGenerator

Hierarchy

Expanded class hierarchy of CachedClassMapGenerator

1 file declares its use of CachedClassMapGenerator
ServiceFactory.php in lib/DIC/ServiceFactory.php

File

lib/Discovery/CachedClassMapGenerator.php, line 6

Namespace

Drupal\xautoload\Discovery
View source
class CachedClassMapGenerator implements ClassMapGeneratorInterface {

  /**
   * @var ClassMapGeneratorInterface
   */
  protected $decorated;

  /**
   * @param ClassMapGeneratorInterface $decorated
   */
  function __construct($decorated) {
    $this->decorated = $decorated;
  }

  /**
   * @param string[] $paths
   *
   * @return string[]
   */
  function wildcardPathsToClassmap($paths) {

    // Attempt to load from cache.
    $cid = 'xautoload:wildcardPathsToClassmap:' . md5(serialize($paths));
    $cache = cache_get($cid);
    if ($cache && isset($cache->data)) {
      return $cache->data;
    }

    // Resolve cache miss and save.
    $map = $this->decorated
      ->wildcardPathsToClassmap($paths);
    cache_set($cid, $map);
    return $map;
  }

}

Members