class CacheFactoryWrapper

Wraps a cache factory to register all calls to the cache system.

Hierarchy

  • class \Drupal\webprofiler\Cache\CacheFactoryWrapper implements \Drupal\Core\Cache\CacheFactoryInterface, \Symfony\Component\DependencyInjection\ContainerAwareInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait

Expanded class hierarchy of CacheFactoryWrapper

1 string reference to 'CacheFactoryWrapper'
webprofiler.services.yml in webprofiler/webprofiler.services.yml
webprofiler/webprofiler.services.yml
1 service uses CacheFactoryWrapper
webprofiler.debug.cache_factory in webprofiler/webprofiler.services.yml
Drupal\webprofiler\Cache\CacheFactoryWrapper

File

webprofiler/src/Cache/CacheFactoryWrapper.php, line 13

Namespace

Drupal\webprofiler\Cache
View source
class CacheFactoryWrapper implements CacheFactoryInterface, ContainerAwareInterface {
    use ContainerAwareTrait;
    
    /**
     * The cache factory.
     *
     * @var \Drupal\Core\Cache\CacheFactoryInterface
     */
    protected $cacheFactory;
    
    /**
     * The cache data collector.
     *
     * @var \Drupal\webprofiler\DataCollector\CacheDataCollector
     */
    protected $cacheDataCollector;
    
    /**
     * All wrapped cache backends.
     *
     * @var \Drupal\webprofiler\Cache\CacheBackendWrapper[]
     */
    protected $cacheBackends = [];
    
    /**
     * Creates a new CacheFactoryWrapper instance.
     *
     * @param \Drupal\Core\Cache\CacheFactoryInterface $cache_factory
     *   The cache factory.
     * @param \Drupal\webprofiler\DataCollector\CacheDataCollector $cacheDataCollector
     *   The cache data collector.
     */
    public function __construct(CacheFactoryInterface $cache_factory, CacheDataCollector $cacheDataCollector) {
        $this->cacheFactory = $cache_factory;
        $this->cacheDataCollector = $cacheDataCollector;
    }
    
    /**
     * {@inheritdoc}
     */
    public function get($bin) {
        if (!isset($this->cacheBackends[$bin])) {
            $cache_backend = $this->cacheFactory
                ->get($bin);
            $this->cacheBackends[$bin] = new CacheBackendWrapper($this->cacheDataCollector, $cache_backend, $bin);
        }
        return $this->cacheBackends[$bin];
    }

}

Members

Title Sort descending Modifiers Object type Summary
CacheFactoryWrapper::$cacheBackends protected property All wrapped cache backends.
CacheFactoryWrapper::$cacheDataCollector protected property The cache data collector.
CacheFactoryWrapper::$cacheFactory protected property The cache factory.
CacheFactoryWrapper::get public function
CacheFactoryWrapper::__construct public function Creates a new CacheFactoryWrapper instance.