/** * Retrieve cache frontend instance by a cache type identifier, enforcing identifier-scoped access control * * @param string $cacheType Cache type identifier * @return \Magento\Framework\Cache\FrontendInterface Cache frontend instance */ public function get($cacheType) { if (!isset($this->_instances[$cacheType])) { $frontendId = $this->_getCacheFrontendId($cacheType); $frontendInstance = $this->_frontendPool->get($frontendId); /** @var $frontendInstance AccessProxy */ $frontendInstance = $this->_objectManager->create('Magento\\Framework\\App\\Cache\\Type\\AccessProxy', ['frontend' => $frontendInstance, 'identifier' => $cacheType]); $this->_instances[$cacheType] = $frontendInstance; } return $this->_instances[$cacheType]; }
/** * @param State\OptionsInterface $options * @param \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool * @param \Magento\Framework\App\State $appState * @param bool $banAll Whether all cache types are forced to be disabled */ public function __construct(State\OptionsInterface $options, \Magento\Framework\App\Cache\Frontend\Pool $cacheFrontendPool, \Magento\Framework\App\State $appState, $banAll = false) { $this->_options = $options; $this->_cacheFrontend = $cacheFrontendPool->get(\Magento\Framework\App\Cache\Frontend\Pool::DEFAULT_FRONTEND_ID); if ($appState->isInstalled()) { $this->_loadTypeStatuses($banAll); } }
/** * @param \Magento\Framework\App\Cache\Frontend\Pool $frontendPool */ public function __construct(\Magento\Framework\App\Cache\Frontend\Pool $frontendPool) { $this->_frontendPool = $frontendPool; $this->_frontend = $frontendPool->get($this->_frontendIdentifier); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage Cache frontend 'unknown' is not recognized */ public function testGetUnknownFrontendId() { $this->_model->get('unknown'); }