diff --git a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php index 78884cc..7962aef 100644 --- a/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php +++ b/core/lib/Drupal/Core/Entity/TypedData/EntityDataDefinition.php @@ -58,6 +58,12 @@ public static function createFromDataType($data_type) { public function getPropertyDefinitions() { if (!isset($this->propertyDefinitions)) { if ($entity_type_id = $this->getEntityTypeId()) { + // Fail with an exception for entity types which don't support type data. + $entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass(); + if (!in_array('Drupal\Core\TypedData\TypedDataInterface', class_implements($entity_type_class))) { + throw new \InvalidArgumentException(String::format('The %entity_type entity type does not support data definitions.', array('%entity_type' => $entity_type_id))); + } + // @todo: Add support for handling multiple bundles. // See https://drupal.org/node/2169813. $bundles = $this->getBundles(); @@ -102,12 +108,6 @@ public function getEntityTypeId() { * {@inheritdoc} */ public function setEntityTypeId($entity_type_id) { - // Fail with an exception for entity types which don't support type data. - $entity_type_class = \Drupal::entityManager()->getDefinition($entity_type_id)->getClass(); - if (!in_array('Drupal\Core\TypedData\TypedDataInterface', class_implements($entity_type_class))) { - throw new \InvalidArgumentException(String::format('The %entity_type entity type does not support data definitions.', array('%entity_type' => $entity_type_id))); - } - return $this->addConstraint('EntityType', $entity_type_id); }