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


PHP CacheableMetadata::merge方法代碼示例

本文整理匯總了PHP中Drupal\Core\Cache\CacheableMetadata::merge方法的典型用法代碼示例。如果您正苦於以下問題:PHP CacheableMetadata::merge方法的具體用法?PHP CacheableMetadata::merge怎麽用?PHP CacheableMetadata::merge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Drupal\Core\Cache\CacheableMetadata的用法示例。


在下文中一共展示了CacheableMetadata::merge方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: addCacheableDependency

 /**
  * {@inheritdoc}
  */
 public function addCacheableDependency($dependency)
 {
     // A trait doesn't have a constructor, so initialize the cacheability
     // metadata if that hasn't happened yet.
     if (!isset($this->cacheabilityMetadata)) {
         $this->cacheabilityMetadata = new CacheableMetadata();
     }
     $this->cacheabilityMetadata = $this->cacheabilityMetadata->merge(CacheableMetadata::createFromObject($dependency));
     return $this;
 }
開發者ID:ddrozdik,項目名稱:dmaps,代碼行數:13,代碼來源:CacheableResponseTrait.php

示例2: testMerge

 /**
  * @covers ::merge
  * @dataProvider providerTestMerge
  *
  * This only tests at a high level, because it reuses existing logic. Detailed
  * tests exist for the existing logic:
  *
  * @see \Drupal\Tests\Core\Cache\CacheTest::testMergeTags()
  * @see \Drupal\Tests\Core\Cache\CacheTest::testMergeMaxAges()
  * @see \Drupal\Tests\Core\Cache\CacheContextsTest
  */
 public function testMerge(CacheableMetadata $a, CacheableMetadata $b, CacheableMetadata $expected)
 {
     $cache_contexts_manager = $this->getMockBuilder('Drupal\\Core\\Cache\\CacheContextsManager')->disableOriginalConstructor()->getMock();
     $container = new ContainerBuilder();
     $container->set('cache_contexts_manager', $cache_contexts_manager);
     \Drupal::setContainer($container);
     $this->assertEquals($expected, $a->merge($b));
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:19,代碼來源:CacheableMetadataTest.php

示例3: merge

 /**
  * Merges the values of another bubbleable metadata object with this one.
  *
  * @param \Drupal\Core\Cache\CacheableMetadata $other
  *   The other bubbleable metadata object.
  *
  * @return static
  *   A new bubbleable metadata object, with the merged data.
  */
 public function merge(CacheableMetadata $other)
 {
     $result = parent::merge($other);
     if ($other instanceof BubbleableMetadata) {
         $result->attached = \Drupal::service('renderer')->mergeAttachments($this->attached, $other->attached);
         $result->postRenderCache = NestedArray::mergeDeep($this->postRenderCache, $other->postRenderCache);
     }
     return $result;
 }
開發者ID:nstielau,項目名稱:drops-8,代碼行數:18,代碼來源:BubbleableMetadata.php

示例4: merge

 /**
  * Merges the values of another bubbleable metadata object with this one.
  *
  * @param \Drupal\Core\Cache\CacheableMetadata $other
  *   The other bubbleable metadata object.
  *
  * @return static
  *   A new bubbleable metadata object, with the merged data.
  */
 public function merge(CacheableMetadata $other)
 {
     $result = parent::merge($other);
     // This is called many times per request, so avoid merging unless absolutely
     // necessary.
     if ($other instanceof BubbleableMetadata) {
         if (empty($this->attachments)) {
             $result->attachments = $other->attachments;
         } elseif (empty($other->attachments)) {
             $result->attachments = $this->attachments;
         } else {
             $result->attachments = static::mergeAttachments($this->attachments, $other->attachments);
         }
     }
     return $result;
 }
開發者ID:aWEBoLabs,項目名稱:taxi,代碼行數:25,代碼來源:BubbleableMetadata.php

示例5: addCacheableDependency

 /**
  * {@inheritdoc}
  */
 public function addCacheableDependency($dependency)
 {
     $this->cacheabilityMetadata = $this->cacheabilityMetadata->merge(CacheableMetadata::createFromObject($dependency));
     return $this;
 }
開發者ID:HakS,項目名稱:drupal8_training,代碼行數:8,代碼來源:Context.php


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