diff --git a/core/lib/Drupal/Core/Entity/Entity.php b/core/lib/Drupal/Core/Entity/Entity.php index fa91cbd..1f0d248 100644 --- a/core/lib/Drupal/Core/Entity/Entity.php +++ b/core/lib/Drupal/Core/Entity/Entity.php @@ -550,8 +550,11 @@ public function getTypedData() { if (!isset($this->typedData)) { // Create the data definition and let the typed data manager instantiate // the corresponding typed data object. - $definition = EntityDataDefinition::create() - ->setEntityTypeId($this->getEntityTypeId()); + $definition = EntityDataDefinition::create($this->getEntityTypeId()); + // Inject the field definitions used by the entity. + if (in_array('Drupal\Core\Entity\FieldableEntityInterface', class_implements($this))) { + $definition->setPropertyDefinitions($this->getFieldDefinitions()); + } // Some places in core create entities with fake/non-existing bundles. In // such cases, setting the bundle on the definition would result in a // non-existing data type, since derived 'entity:[entity_type]:[bundle]' diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index 95f44a9..eb2584c 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -82,6 +82,10 @@ public function getPropertyDefinitions() { return $this->propertyDefinitions; } + public function setPropertyDefinitions(array $definitions) { + $this->propertyDefinitions = $definitions; + } + /** * {@inheritdoc} */