当前位置: 首页>>代码示例>>PHP>>正文


PHP NodeInterface::getTypedData方法代码示例

本文整理汇总了PHP中Drupal\node\NodeInterface::getTypedData方法的典型用法代码示例。如果您正苦于以下问题:PHP NodeInterface::getTypedData方法的具体用法?PHP NodeInterface::getTypedData怎么用?PHP NodeInterface::getTypedData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Drupal\node\NodeInterface的用法示例。


在下文中一共展示了NodeInterface::getTypedData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testBubbleableMetadata

 /**
  * @cover replacePlaceHolders
  */
 public function testBubbleableMetadata()
 {
     // Make sure the bubbleable metadata added by the fetcher is properly passed
     // though.
     $bubbleable_metadata = new BubbleableMetadata();
     // Save the node, so it gets a cache tag.
     $this->node->save();
     $this->placeholderResolver->replacePlaceHolders('test {{node.field_integer}}', ['node' => $this->node->getTypedData()], $bubbleable_metadata);
     $expected = ['node:' . $this->node->id()];
     $this->assertEquals($expected, $bubbleable_metadata->getCacheTags());
     // Ensure cache tags of filters are added in.
     $bubbleable_metadata = new BubbleableMetadata();
     $this->placeholderResolver->replacePlaceHolders("test {{ node.created.value | format_date('medium') }}", ['node' => $this->node->getTypedData()], $bubbleable_metadata);
     $expected = Cache::mergeTags(['node:' . $this->node->id()], DateFormat::load('medium')->getCacheTags());
     $this->assertEquals($expected, $bubbleable_metadata->getCacheTags());
 }
开发者ID:Progressable,项目名称:openway8,代码行数:19,代码来源:PlaceholderResolverTest.php

示例2: testBubbleableMetadata

 /**
  * @cover fetchDataByPropertyPath
  */
 public function testBubbleableMetadata()
 {
     $this->node->field_integer->setValue([]);
     // Save the node, so that it gets an ID and it has a cache tag.
     $this->node->save();
     // Also add a user for testing cache tags of references.
     $user = $this->entityTypeManager->getStorage('user')->create(['name' => 'test', 'type' => 'user']);
     $user->save();
     $this->node->uid->entity = $user;
     $bubbleable_metadata = new BubbleableMetadata();
     $this->dataFetcher->fetchDataByPropertyPath($this->node->getTypedData(), 'title.value', $bubbleable_metadata)->getValue();
     $expected = ['node:' . $this->node->id()];
     $this->assertEquals($expected, $bubbleable_metadata->getCacheTags());
     // Test cache tags of references are added correctly.
     $this->dataFetcher->fetchDataByPropertyPath($this->node->getTypedData(), 'uid.entity.name', $bubbleable_metadata)->getValue();
     $expected = ['node:' . $this->node->id(), 'user:' . $user->id()];
     $this->assertEquals($expected, $bubbleable_metadata->getCacheTags());
 }
开发者ID:Progressable,项目名称:openway8,代码行数:21,代码来源:DataFetcherTest.php


注:本文中的Drupal\node\NodeInterface::getTypedData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。