+ $data_type = "entity:{$entity_type_id}";
+
+ // If a bundle was given, use the bundle-specific definition.
+ if ($bundle) {
+ $data_type .= ":{$bundle}";
+ }
+
+ // It's possible that the given entity type ID or bundle wasn't discovered
+ // by the TypedData plugin manager and/or weren't created by the
+ // EntityDeriver. In that case, this is a new definition and we'll just
+ // create the definition from defaults by using an empty array.
+ $values = \Drupal::typedDataManager()->getDefinition($data_type, FALSE);
+ $definition = new static(is_array($values) ? $values : []);
+
+ // Set the EntityType constraint using the given entity type ID.