當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Layout::isCacheable方法代碼示例

本文整理匯總了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;
 }
開發者ID:aiesh,項目名稱:magento2,代碼行數:26,代碼來源:LayoutPlugin.php

示例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;
 }
開發者ID:cloudflare,項目名稱:cloudflare-magento,代碼行數:23,代碼來源:LayoutPlugin.php

示例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());
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:11,代碼來源:LayoutTest.php

示例4: isCacheable

 /**
  * @return bool
  */
 public function isCacheable()
 {
     return $this->isCacheable && parent::isCacheable();
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:7,代碼來源:Layout.php

示例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());
 }
開發者ID:andrewhowdencom,項目名稱:m2onk8s,代碼行數:6,代碼來源:LayoutTest.php

示例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);
     }
 }
開發者ID:HaonanXu,項目名稱:der-snack-backup,代碼行數:12,代碼來源:Interceptor.php


注:本文中的Magento\Framework\View\Layout::isCacheable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。