EntityDisplayBase::getFieldDefinitions() checks that the $entity_type the Display applies to is Fieldable :
// Entity displays are sometimes created for non-content entities.
// @todo Prevent this in https://drupal.org/node/2095195.
if (!\Drupal::entityManager()->getDefinition($this->targetEntityType)->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
return array();
}
That same check is performed in the __construct() :
if (!$this->entityManager()->getDefinition($values['targetEntityType'])->isSubclassOf('\Drupal\Core\Entity\FieldableEntityInterface')) {
throw new \InvalidArgumentException('EntityDisplay entities can only handle content entity types.');
}
- We could remove the check in getFieldDefinitions()
- Not sure why we check Fieldable. EntityDisplays should be about ContentEntities, but no reason to limit to those with fields.. OK, FieldableEntitiyInterface is larger than ContentEntityInterface. Then the exception message needs to be updated.