If I create an entity reference field (not file field) that can reference files, I'm able to use the default 'Rendered entity' formatter. Problem is, for files, this renders nothing. Without a module like File Entity available, entity_view() does nothing for files.
A node with a entity reference field referencing a file:
No output visible
HTML output showing nothing:
We have to special case file entities in Entity Embed, but my concern is that other things may try to render entities that have a view builder class, but are not actually viewable.
Add a isViewable() method with corresponding property to \Drupal\Core\Entity\EntityType. I tried setting 'view_builder' => NULL in the annotation for \Drupal\file\Entity\File but it breaks rendering any base fields on files, which is used for the file listing page at /admin/content/file.
* Write change notice
User interface changes
This adds a 'viewable' property to \Drupal\Core\Entity\EntityType, default to FALSE. \Drupal\Core\Entity\ContentEntityType overrides this with TRUE since it also is responsible for adding the default view_builder handler. No change in behavior.
Data model changes
Beta phase evaluation
|Issue category||Bug because users are tricked into using a formatter that cannot be used.|
|Issue priority||Not critical because most people will use file fields, but this affects contributed modules like Entity Embed.|
|Unfrozen changes||Unfrozen because it solves something that never worked in the first place.|
|Disruption||Disruptive for any contrib modules that had un-viewable entities that used ContentEntityType. Of my knowledge there are no such contrib modules, and core's file module is the only known example to me.|
|#18||Selection_302.png||70.02 KB||Dave Reid|
|#9||interdiff.txt||1.04 KB||Dave Reid|
|#9||2567919-file-entity-disable-view-builder.patch||4.32 KB||Dave Reid|
PASSED: [[SimpleTest]]: [PHP 5.5 MySQL] 112,641 pass(es). View
|#2||2567919-file-entity-disable-view-builder.patch||494 bytes||Dave Reid|
FAILED: [[SimpleTest]]: [PHP 5.5 MySQL] 112,627 pass(es), 20 fail(s), and 0 exception(s). View
|Selection_295.png||26.34 KB||Dave Reid|