当前位置: 首页>>代码示例>>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;未经允许,请勿转载。