本文整理匯總了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;
}