本文整理汇总了PHP中Magento\Framework\App\Config\ScopeConfigInterface::isEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP ScopeConfigInterface::isEnabled方法的具体用法?PHP ScopeConfigInterface::isEnabled怎么用?PHP ScopeConfigInterface::isEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\App\Config\ScopeConfigInterface
的用法示例。
在下文中一共展示了ScopeConfigInterface::isEnabled方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aroundRenderResult
/**
* @param \Magento\Framework\Controller\ResultInterface $subject
* @param callable $proceed
* @param ResponseHttp $response
* @return \Magento\Framework\Controller\ResultInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundRenderResult(\Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response)
{
$result = $proceed($response);
$usePlugin = $this->registry->registry('use_page_cache_plugin');
if (!$usePlugin || !$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) {
return $result;
}
if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
$cacheControlHeader = $response->getHeader('Cache-Control');
if ($cacheControlHeader instanceof \Zend\Http\Header\HeaderInterface) {
$response->setHeader('X-Magento-Cache-Control', $cacheControlHeader->getFieldValue());
}
$response->setHeader('X-Magento-Cache-Debug', 'MISS', true);
}
$tagsHeader = $response->getHeader('X-Magento-Tags');
$tags = [];
if ($tagsHeader) {
$tags = explode(',', $tagsHeader->getFieldValue());
$response->clearHeader('X-Magento-Tags');
}
$tags = array_unique(array_merge($tags, [\Magento\PageCache\Model\Cache\Type::CACHE_TAG]));
$response->setHeader('X-Magento-Tags', implode(',', $tags));
$this->kernel->process($response);
return $result;
}
示例2: execute
/**
* Purges CloudFlare cache by tag
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if (!$this->config->isEnabled()) {
return;
}
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface === false || empty($object->getIdentities())) {
return;
}
$this->cacheTags->purgeCacheTags($object->getIdentities());
}
示例3: aroundDispatch
/**
* @param \Magento\Framework\App\FrontControllerInterface $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @return false|\Magento\Framework\App\Response\Http|\Magento\Framework\Controller\ResultInterface
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
$response = $proceed($request);
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled() && $response instanceof \Magento\Framework\App\Response\Http) {
$this->version->process();
if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
$response->setHeader('X-Magento-Debug', 1);
}
}
return $response;
}
示例4: aroundRenderResult
/**
* @param \Magento\Framework\Controller\ResultInterface $subject
* @param callable $proceed
* @param ResponseHttp $response
* @return \Magento\Framework\Controller\ResultInterface
*/
public function aroundRenderResult(\Magento\Framework\Controller\ResultInterface $subject, \Closure $proceed, ResponseHttp $response)
{
$proceed($response);
$usePlugin = $this->registry->registry('use_page_cache_plugin');
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled() && $usePlugin) {
$this->version->process();
if ($this->state->getMode() == \Magento\Framework\App\State::MODE_DEVELOPER) {
$response->setHeader('X-Magento-Debug', 1);
}
}
return $subject;
}
示例5: execute
/**
* If Varnish caching is enabled it collects array of tags
* of incoming object and asks to clean cache.
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
if ($this->config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->config->isEnabled()) {
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
$tags = [];
$pattern = "((^|,)%s(,|\$))";
foreach ($object->getIdentities() as $tag) {
$tags[] = sprintf($pattern, preg_replace("~_\\d+\$~", '', $tag));
$tags[] = sprintf($pattern, $tag);
}
$this->purgeCache->sendPurgeRequest(implode('|', array_unique($tags)));
}
}
}
示例6: aroundDispatch
/**
* @param \Magento\Framework\App\FrontControllerInterface $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @return \Magento\Framework\Controller\ResultInterface|\Magento\Framework\App\Response\Http
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function aroundDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if (!$this->config->isEnabled() || $this->config->getType() != \Magento\PageCache\Model\Config::BUILT_IN) {
return $proceed($request);
}
$this->version->process();
$result = $this->kernel->load();
if ($result === false) {
$result = $proceed($request);
if ($result instanceof ResponseHttp) {
$this->addDebugHeaders($result);
$this->kernel->process($result);
}
} else {
$this->addDebugHeader($result, 'X-Magento-Cache-Debug', 'HIT', true);
}
return $result;
}
示例7: aroundDispatch
/**
* @param \Magento\Framework\App\FrontControllerInterface $subject
* @param callable $proceed
* @param \Magento\Framework\App\RequestInterface $request
* @return false|\Magento\Framework\App\Response\Http
*/
public function aroundDispatch(\Magento\Framework\App\FrontControllerInterface $subject, \Closure $proceed, \Magento\Framework\App\RequestInterface $request)
{
if ($this->config->getType() == \Magento\PageCache\Model\Config::BUILT_IN && $this->config->isEnabled()) {
$this->version->process();
$response = $this->kernel->load();
if ($response === false) {
$response = $proceed($request);
$cacheControl = $response->getHeader('Cache-Control')['value'];
$this->addDebugHeader($response, 'X-Magento-Cache-Control', $cacheControl);
$this->kernel->process($response);
$this->addDebugHeader($response, 'X-Magento-Cache-Debug', 'MISS');
} else {
$this->addDebugHeader($response, 'X-Magento-Cache-Debug', 'HIT');
}
} else {
return $response = $proceed($request);
}
return $response;
}
示例8: execute
/**
* Flush CloudFlare cache
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(Observer $observer)
{
if ($this->config->isEnabled()) {
$this->cacheTags->purgeCache();
}
}
示例9: flushAllCache
/**
* Flash Varnish cache
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
* @SuppressWarnings(PHPMD.UnusedFormalParameter)
*/
public function flushAllCache(\Magento\Framework\Event\Observer $observer)
{
if ($this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH && $this->_config->isEnabled()) {
$this->sendPurgeRequest('.*');
}
}