本文整理汇总了PHP中Magento\PageCache\Model\Config::getType方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::getType方法的具体用法?PHP Config::getType怎么用?PHP Config::getType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\PageCache\Model\Config
的用法示例。
在下文中一共展示了Config::getType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isVarnishEnabled
/**
* Is varnish cache engine enabled
*
* @return bool
*/
protected function isVarnishEnabled()
{
if ($this->isVarnishEnabled === null) {
$this->isVarnishEnabled = $this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH;
}
return $this->isVarnishEnabled;
}
示例2: execute
/**
* If Built-In 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::BUILT_IN && $this->_config->isEnabled()) {
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\DataObject\IdentityInterface) {
$tags = $object->getIdentities();
if (!empty($tags)) {
$this->getCache()->clean(\Zend_Cache::CLEANING_MODE_MATCHING_ANY_TAG, array_unique($tags));
}
}
}
}
示例3: execute
/**
* If Built-In 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::BUILT_IN && $this->_config->isEnabled()) {
$object = $observer->getEvent()->getObject();
if ($object instanceof \Magento\Framework\Object\IdentityInterface) {
$tags = $object->getIdentities();
foreach ($tags as $tag) {
$tags[] = preg_replace("~_\\d+\$~", '', $tag);
}
$this->_cache->clean(array_unique($tags));
}
}
}
示例4: afterGetOutput
/**
* Retrieve all identities from blocks for further cache invalidation
*
* @param \Magento\Framework\View\Layout $subject
* @param mixed $result
* @return mixed
*/
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
{
if ($subject->isCacheable() && $this->config->isEnabled()) {
$tags = [];
foreach ($subject->getAllBlocks() as $block) {
if ($block instanceof \Magento\Framework\DataObject\IdentityInterface) {
$isEsiBlock = $block->getTtl() > 0;
$isVarnish = $this->config->getType() == \Magento\PageCache\Model\Config::VARNISH;
if ($isVarnish && $isEsiBlock) {
continue;
}
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
$this->response->setHeader('X-Magento-Tags', implode(',', $tags));
}
return $result;
}
示例5: execute
/**
* Add comment cache containers to private blocks
* Blocks are wrapped only if page is cacheable
*
* @param \Magento\Framework\Event\Observer $observer
* @return void
*/
public function execute(\Magento\Framework\Event\Observer $observer)
{
$event = $observer->getEvent();
/** @var \Magento\Framework\View\Layout $layout */
$layout = $event->getLayout();
if ($layout->isCacheable() && $this->_config->isEnabled()) {
$name = $event->getElementName();
$block = $layout->getBlock($name);
$transport = $event->getTransport();
if ($block instanceof \Magento\Framework\View\Element\AbstractBlock) {
$blockTtl = $block->getTtl();
$varnishIsEnabledFlag = $this->_config->getType() == \Magento\PageCache\Model\Config::VARNISH;
$output = $transport->getData('output');
if ($varnishIsEnabledFlag && isset($blockTtl)) {
$output = $this->_wrapEsi($block, $layout);
} elseif ($block->isScopePrivate()) {
$output = sprintf('<!-- BLOCK %1$s -->%2$s<!-- /BLOCK %1$s -->', $block->getNameInLayout(), $output);
}
$transport->setData('output', $output);
}
}
}
示例6: flushAllCache
/**
* Flash Built-In 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::BUILT_IN) {
$this->_cache->clean();
}
}
示例7: execute
/**
* Flash Built-In cache
*
* @return void
*/
public function execute()
{
if ($this->_config->getType() == \Magento\PageCache\Model\Config::BUILT_IN) {
$this->_cache->clean();
}
}