You are here

class VariationCacheFactory in VariationCache 8

Defines the variation cache factory.

Hierarchy

Expanded class hierarchy of VariationCacheFactory

1 string reference to 'VariationCacheFactory'
variationcache.services.yml in ./variationcache.services.yml
variationcache.services.yml
1 service uses VariationCacheFactory
variation_cache_factory in ./variationcache.services.yml
Drupal\variationcache\Cache\VariationCacheFactory

File

src/Cache/VariationCacheFactory.php, line 14

Namespace

Drupal\variationcache\Cache
View source
class VariationCacheFactory implements VariationCacheFactoryInterface {

  /**
   * Instantiated variation cache bins.
   *
   * @var \Drupal\variationcache\Cache\VariationCacheInterface[]
   */
  protected $bins = [];

  /**
   * The request stack.
   *
   * @var \Symfony\Component\HttpFoundation\RequestStack
   */
  protected $requestStack;

  /**
   * The cache factory.
   *
   * @var \Drupal\Core\Cache\CacheFactoryInterface
   */
  protected $cacheFactory;

  /**
   * The cache contexts manager.
   *
   * @var \Drupal\Core\Cache\Context\CacheContextsManager
   */
  protected $cacheContextsManager;

  /**
   * Constructs a new VariationCacheFactory object.
   *
   * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
   *   The request stack.
   * @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
   *   The cache factory.
   * @param \Drupal\Core\Cache\Context\CacheContextsManager $cache_contexts_manager
   *   The cache contexts manager.
   */
  public function __construct(RequestStack $request_stack, CacheFactoryInterface $cache_factory, CacheContextsManager $cache_contexts_manager) {
    $this->requestStack = $request_stack;
    $this->cacheFactory = $cache_factory;
    $this->cacheContextsManager = $cache_contexts_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function get($bin) {
    if (!isset($this->bins[$bin])) {
      $this->bins[$bin] = new VariationCache($this->requestStack, $this->cacheFactory
        ->get($bin), $this->cacheContextsManager);
    }
    return $this->bins[$bin];
  }

}

Members

Namesort descending Modifiers Type Description Overrides
VariationCacheFactory::$bins protected property Instantiated variation cache bins.
VariationCacheFactory::$cacheContextsManager protected property The cache contexts manager.
VariationCacheFactory::$cacheFactory protected property The cache factory.
VariationCacheFactory::$requestStack protected property The request stack.
VariationCacheFactory::get public function Gets a variation cache backend for a given cache bin. Overrides VariationCacheFactoryInterface::get
VariationCacheFactory::__construct public function Constructs a new VariationCacheFactory object.