本文整理匯總了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);
}
}