本文整理汇总了PHP中Drupal\Core\Entity\ContentEntityInterface::getTypedData方法的典型用法代码示例。如果您正苦于以下问题:PHP ContentEntityInterface::getTypedData方法的具体用法?PHP ContentEntityInterface::getTypedData怎么用?PHP ContentEntityInterface::getTypedData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Drupal\Core\Entity\ContentEntityInterface
的用法示例。
在下文中一共展示了ContentEntityInterface::getTypedData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: assertPropertyPath
/**
* Asserts that a context for the given property path can be derived.
*
* @param \Drupal\Core\Entity\ContentEntityInterface $entity
* The entity to test with.
* @param $property_path
* The property path to look for.
* @param $expected_data_type
* The expected data type.
*
* @return \Drupal\Core\Plugin\Context\ContextInterface
* The context with a value.
*/
protected function assertPropertyPath(ContentEntityInterface $entity, $property_path, $expected_data_type)
{
$typed_data_entity = $entity->getTypedData();
$context_definition = new ContextDefinition($typed_data_entity->getDataDefinition()->getDataType());
$context_with_value = new Context($context_definition, $typed_data_entity);
$context_without_value = new Context($context_definition);
// Test the context without value.
$property_context = $this->typedDataResolver->getContextFromProperty($property_path, $context_without_value);
$this->assertEquals($expected_data_type, $property_context->getContextDefinition()->getDataType());
// Test the context with value.
$property_context = $this->typedDataResolver->getContextFromProperty($property_path, $context_with_value);
$this->assertEquals($expected_data_type, $property_context->getContextDefinition()->getDataType());
// Return the context with value so it can be asserted.
return $property_context;
}