本文整理汇总了PHP中Magento\Framework\View\Layout::isCacheable方法的典型用法代码示例。如果您正苦于以下问题:PHP Layout::isCacheable方法的具体用法?PHP Layout::isCacheable怎么用?PHP Layout::isCacheable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Magento\Framework\View\Layout
的用法示例。
在下文中一共展示了Layout::isCacheable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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 ($this->layout->isCacheable() && $this->config->isEnabled()) {
$tags = array();
foreach ($this->layout->getAllBlocks() as $block) {
if ($block instanceof \Magento\Framework\View\Block\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;
}
示例2: afterGetOutput
/**
* Set X-Cache-Tags header with all the Magento Cache Tags so
* they can be purged by the CloudFlare API
*
* @param \Magento\Framework\View\Layout $subject
* @param $result
* @return mixed
*/
public function afterGetOutput(\Magento\Framework\View\Layout $subject, $result)
{
if (!$subject->isCacheable() || !$this->config->isEnabled()) {
return $result;
}
$tags = [];
foreach ($subject->getAllBlocks() as $block) {
if ($block->getIdentities() !== null) {
$tags = array_merge($tags, $block->getIdentities());
}
}
$tags = array_unique($tags);
$this->cacheTagsUtil->setCloudFlareCacheTagsResponseHeader($this->response, $tags);
return $result;
}
示例3: testIsCacheable
/**
* @param string $xmlString
* @param bool $result
* @dataProvider isCacheableDataProvider
*/
public function testIsCacheable($xmlString, $result)
{
$xml = simplexml_load_string($xmlString, 'Magento\\Framework\\View\\Layout\\Element');
$this->assertSame($this->model, $this->model->setXml($xml));
$this->assertSame($result, $this->model->isCacheable());
}
示例4: isCacheable
/**
* @return bool
*/
public function isCacheable()
{
return $this->isCacheable && parent::isCacheable();
}
示例5: testIsNonCacheable
public function testIsNonCacheable()
{
$this->_layout->setXml(simplexml_load_file(__DIR__ . '/_files/layout/non_cacheable.xml', 'Magento\\Framework\\View\\Layout\\Element'));
$this->_layout->generateElements();
$this->assertFalse($this->_layout->isCacheable());
}
示例6: isCacheable
/**
* {@inheritdoc}
*/
public function isCacheable()
{
$pluginInfo = $this->pluginList->getNext($this->subjectType, 'isCacheable');
if (!$pluginInfo) {
return parent::isCacheable();
} else {
return $this->___callPlugins('isCacheable', func_get_args(), $pluginInfo);
}
}