Updated: Comment #N

Problem/Motivation

In preparation for #2031717: Make entity module not required - let's make sure all interfaces exposed by the entity API are below the core component.

Solution

Move the entity display interface below the core component and separate them from their config entities, as being a config-entity is nothing that we require for entity display.

Changes:
entity\EntityDisplayBaseInterface -> Core\Entity\Display\EntityDisplayInterface
entity\EntityDisplayInterface -> Core\Entity\Display\EntityViewDisplayInterface
entity\EntityDisplayInterface -> Core\Entity\Display\EntityViewDisplayInterface
entity\EntityFormDisplayInterface -> Core\Entity\Display\EntityFormDisplayInterface
entity\EntityDisplayBaseInterface -> Core\Entity\Display\EntityDisplayInterface
EntityViewDisplayInterface, EntityFormDisplayInterface do not extend ConfigEntityInterface any more

The patch does not add separate EntityViewDisplay or EntityFormDisplay interfaces just for the config entities (what we usually do) as we figured you'd usually type-hint on the general non-entity type specific interfaces anyway.

Follow-up tasks

Rename the "entity_display" config entity, along with its class name and hook_entity_display_alter() to entity_view_display.

User interface changes

None.

API changes

ViewBuilder, FormController, as well as entity-view hooks are slightly changed to use the interfaces below the core component now.

Original report by @username

Attached patch separates the existing entity-display config-entity interfaces CRUD stuff from the actualy display-related logic that imho belongs in the API only and moves the general interfaces to the core component. The object being passed in is a CMI object is an implementation detail and nothing that should be required for being able to render/edit a simple entity.

With that patch all interfaces part of entity.api.php are in the core component.

CommentFileSizeAuthor
#87 d8_entity_display.interdiff.txt3 KBfago
#87 d8_entity_display.patch47.37 KBfago
#83 d8_entity_display.patch48.86 KBfago
#72 d8_entity_display.patch47.31 KBfago
#64 d8_entity_display.interdiff.txt2.8 KBfago
#64 d8_entity_display.patch47.31 KBfago
#58 d8_entity_display.interdiff.txt33.5 KBfago
#58 d8_entity_display.patch47.63 KBfago
#53 field_interfaces-2031725-53.patch28.24 KBNebel54
#49 field_interfaces-1.patch25 KBvladan.me
#45 field_interfaces.patch24.99 KBvladan.me
#42 field-interfaces-2031725-39.patch27.3 KBvladan.me
#38 field-interfaces-2031725-38.patch24.16 KBBerdir
#34 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch26.21 KBfgm
#32 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch26.07 KBfgm
#27 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch26.17 KBfgm
#27 interdiff-27-24.txt3.52 KBfgm
#24 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch27.94 KBfgm
#21 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch27.79 KBfgm
#20 interdiff.txt4.94 KBfgm
#19 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch27.6 KBfgm
#17 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch22.42 KBfgm
#17 interdiff.txt4.31 KBfgm
#14 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch21.42 KBfgm
#14 interdiff.txt1.39 KBfgm
#9 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch22.9 KBfgm
#7 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch20.02 KBfgm
#5 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch14.91 KBfgm
#2 d8_interface.interdiff.txt3.58 KBfago
#2 d8_interface.patch16.97 KBfago
d8_interface.patch13.39 KBfago
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Status: Needs review » Needs work

The last submitted patch, d8_interface.patch, failed testing.

fago’s picture

Status: Needs work » Needs review
FileSize
16.97 KB
3.58 KB

Missed a few type-hints.

Berdir’s picture

#2: d8_interface.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, d8_interface.patch, failed testing.

fgm’s picture

Status: Needs work » Needs review
FileSize
14.91 KB

Rerolled for today's HEAD.

fago’s picture

Status: Needs review » Needs work
+++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayInterface.php
@@ -7,11 +7,12 @@
  */
-interface EntityDisplayInterface extends EntityDisplayBaseInterface {
+interface EntityDisplayInterface extends EntityViewDisplayInterface, ConfigEntityInterface {

This seems wrong.

+++ b/core/modules/entity/lib/Drupal/entity/EntityFormDisplayInterface.php
@@ -7,11 +7,12 @@
-interface EntityFormDisplayInterface extends EntityDisplayBaseInterface {
+interface EntityFormDisplayInterface extends CoreEntityFormDisplayInterface, ConfigEntityInterface {

As discussed, let's follow the actions example and add the "ConfigEntity" suffix to interface extending the ConfigEntityInterface.

-> e.g. EntityFormDisplayConfigEntityInterface

fgm’s picture

Status: Needs work » Needs review
FileSize
20.02 KB

This should be it.

Status: Needs review » Needs work

The last submitted patch, 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch, failed testing.

fgm’s picture

Status: Needs work » Needs review
FileSize
22.9 KB

Should be better: I had missed one replacement.

Status: Needs review » Needs work

The last submitted patch, 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch, failed testing.

fgm’s picture

Status: Needs work » Needs review

Might be a transient error: the test which fails here passes locally on my machine and passes on simpletest.me too. Retrying.

fgm’s picture

Berdir’s picture

Status: Needs review » Needs work
+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AddFeedTest.php
@@ -24,6 +24,7 @@ public static function getInfo() {
   function testAddFeed() {
     $feed = $this->createFeed();
+    debug(gettype($feed), "Feed");
 

+++ b/core/modules/aggregator/lib/Drupal/aggregator/Tests/AggregatorTestBase.php
@@ -59,6 +59,7 @@ function createFeed($feed_url = NULL, array $edit = array()) {
     $this->assertTrue(!empty($fid), 'The feed found in database.');
+    debug($fid, __METHOD__ . "/$fid");

Left-over debugs()

fgm’s picture

Status: Needs work » Needs review
FileSize
1.39 KB
21.42 KB

Ooooppppsssss....

Berdir’s picture

Issue tags: +Entity Field API

Tagging.

fago’s picture

Status: Needs review » Needs work
$ git grep 'Drupal\\entity\\Entity'  -- core/lib/Drupal/Core/Entity/
core/lib/Drupal/Core/Entity/EntityFormController.php:use Drupal\entity\EntityFormDisplayConfigEntityInterface;
core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php:use Drupal\entity\EntityFormDisplayConfigEntityInterface;
core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php:   * @return \Drupal\entity\EntityFormDisplayConfigEntityInterface
core/lib/Drupal/Core/Entity/EntityFormControllerInterface.php:   * @param \Drupal\entity\EntityFormDisplayConfigEntityInterface $form_display
core/lib/Drupal/Core/Entity/EntityRenderController.php:use Drupal\entity\Entity\EntityDisplay;
core/lib/Drupal/Core/Entity/EntityRenderController.php:   * @param \Drupal\entity\Entity\EntityDisplay $display

We should not use the config entities in the EntityFormController API, but go with our new interfaces now. This should be the case for interfaces + hooks - hook documentations are already fine.

Ideally, implementations provided Core/Entity would not have any reference to the module also, but this is out-of-scope for this issue for now. So if it's a simple fix we can include it, else it's stuff for #2031717: Make entity module not required.

fgm’s picture

Status: Needs work » Needs review
FileSize
4.31 KB
22.42 KB

This seems to do it. Does it still pass ?

Status: Needs review » Needs work

The last submitted patch, 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch, failed testing.

fgm’s picture

Status: Needs work » Needs review
FileSize
27.6 KB

Looks like I missed one replacement.

fgm’s picture

FileSize
4.94 KB

Forgot to attach interdiff with previous patch.

fgm’s picture

Rerolled after conflicting commits to 8.x yesterday. No changes.

fago’s picture

Status: Needs review » Needs work
+++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
@@ -23,7 +21,7 @@
-   * @return \Drupal\entity\Entity\EntityDisplay

This seems wrong.

+++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
@@ -23,7 +21,7 @@
-   * @return \Drupal\entity\Entity\EntityDisplay
+   * @return \Drupal\entity\Plugin\Core\Entity\EntityDisplay

This seems wrong.

+++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
@@ -56,7 +54,7 @@ public function getComponent($name);
-   * @return \Drupal\entity\Entity\EntityDisplay
+   * @return \Drupal\entity\Plugin\Core\Entity\EntityDisplay

Again.

+++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
@@ -67,7 +65,7 @@ public function setComponent($name, array $options = array());
-   * @return \Drupal\entity\Entity\EntityDisplay
+   * @return \Drupal\entity\Plugin\Core\Entity\EntityDisplay

Again.

Also, \Drupal\entity\Entity\EntityDisplay does not seem to implement the respective interface. But there is a file for EntityDisplayInterface in entity.module which defines it at core namespace.

fgm’s picture

Status: Needs work » Needs review

Rerolled accordingly.

fgm’s picture

oops, patch upload didn't make it.

fago’s picture

Thanks, patch looks good to me now. However we'll need someone else to RTBC as I did the initial patch.

amateescu’s picture

Discussed this a bit with fago and we agreed that there's really not much use for the new Entity[Form]DisplayConfigEntityInterface provided by the entity module. I guess only field_ui could typehint with them if we decide to do something crazy related to the config storage side, but I'd prefer to wait until that happens. In the meantime, they seem a bit over the top so let's remove them :)

fgm’s picture

Only users were EntityDisplay and EntityFormDisplay. Rerolled according to #26.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, I think it's ready now.

Berdir’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Entity Field API

The last submitted patch, 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch, failed testing.

fgm’s picture

Assigned: Unassigned » fgm

Rerolling in a moment.

fgm’s picture

Status: Needs work » Needs review
FileSize
26.07 KB

Rerolled on latest head. Does it still pass ? The only change appears to be the TranslatableInterface on TypedData.

Status: Needs review » Needs work

The last submitted patch, 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch, failed testing.

fgm’s picture

Status: Needs work » Needs review
FileSize
26.21 KB

Seems I has missed one line to remove.

Berdir’s picture

Status: Needs review » Reviewed & tested by the community

Patch is almost identical to the previous one, just a tiny context change.

catch’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Entity Field API

The last submitted patch, 0001-Issue-2031725-by-fago-fgm-Move-entity-API-interfaces.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
24.16 KB

Re-roll.

Status: Needs review » Needs work
Issue tags: -Entity Field API

The last submitted patch, field-interfaces-2031725-38.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
Issue tags: +Entity Field API

#38: field-interfaces-2031725-38.patch queued for re-testing.

tstoeckler’s picture

Status: Needs review » Needs work
  1. +++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
    @@ -2,17 +2,15 @@
    -interface EntityDisplayBaseInterface extends ConfigEntityInterface {
    +interface EntityDisplayInterface {
    

    I like that, that makes a ton of sense. Both the naming and the removed interface.
    ++

  2. +++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
    @@ -23,7 +21,7 @@
    +   * @return \Drupal\Core\Entity\Display\EntityDisplayInterface
    
    @@ -56,7 +54,7 @@ public function getComponent($name);
    -   * @return \Drupal\entity\Entity\EntityDisplay
    +   * @return \Drupal\Core\Entity\Display\EntityDisplayInterface
    
    @@ -67,7 +65,7 @@ public function setComponent($name, array $options = array());
    -   * @return \Drupal\entity\Entity\EntityDisplay
    +   * @return \Drupal\Core\Entity\Display\EntityDisplayInterface
    

    If this were simply following the rename it would be EntityViewDisplay now. But a) this is in EntityDisplayInterface, which knows nothing EntityViewDisplay(Interface) b) typehinting the interface is of course preferred.

    In other words, this should have been EntityBaseDisplayInterface before, so it is in fact a (minor) bugfix.

    Nice!

  3. +++ b/core/lib/Drupal/Core/Entity/EntityRenderController.php
    @@ -136,7 +136,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
    -   * @param \Drupal\entity\Entity\EntityDisplay $display
    +   * @param \Drupal\Core\Entity\Display\EntityDisplayInterface $display
    
    @@ -145,7 +145,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
    -  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) { }
    +  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplayInterface $display, $view_mode, $langcode = NULL) { }
    
    +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockRenderController.php
    @@ -19,7 +19,7 @@ class CustomBlockRenderController extends EntityRenderController {
    -  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
    +  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplayInterface $display, $view_mode, $langcode = NULL) {
    
    +++ b/core/modules/comment/lib/Drupal/comment/CommentRenderController.php
    @@ -146,7 +146,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
    -  protected function alterBuild(array &$build, EntityInterface $comment, EntityDisplay $display, $view_mode, $langcode = NULL) {
    +  protected function alterBuild(array &$build, EntityInterface $comment, EntityDisplayInterface $display, $view_mode, $langcode = NULL) {
    
    +++ b/core/modules/node/lib/Drupal/node/NodeRenderController.php
    @@ -80,7 +80,7 @@ public function buildContent(array $entities, array $displays, $view_mode, $lang
    -  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
    +  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplayInterface $display, $view_mode, $langcode = NULL) {
    
    +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermRenderController.php
    @@ -51,7 +51,7 @@ protected function getBuildDefaults(EntityInterface $entity, $view_mode, $langco
    -  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplay $display, $view_mode, $langcode = NULL) {
    +  protected function alterBuild(array &$build, EntityInterface $entity, EntityDisplayInterface $display, $view_mode, $langcode = NULL) {
    

    This, though should be EntityViewDisplayInterface, if I'm not mistaken.

  4. +++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityDisplay.php
    @@ -31,7 +32,7 @@
    -class EntityDisplay extends EntityDisplayBase implements EntityDisplayInterface {
    +class EntityDisplay extends EntityDisplayBase implements EntityDisplayInterface, ConfigEntityInterface {
    
    +++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php
    @@ -31,7 +32,7 @@
    -class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayInterface, \Serializable {
    +class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayInterface, ConfigEntityInterface, \Serializable {
    
    +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php
    @@ -8,12 +8,13 @@
    -abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDisplayBaseInterface {
    +abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDisplayInterface {
    

    I'm pretty sure EntityDisplay should extend EntityViewDisplayInterface and by extension, be called EntityViewDisplay.

    EntityDisplayBase can then be just EntityDisplay. Also that should directly implement ConfigEntityInterface I think.

  5. +++ b/core/modules/system/entity.api.php
    @@ -426,7 +426,7 @@ function hook_entity_query_alter(\Drupal\Core\Entity\Query\QueryInterface $query
    - * @param \Drupal\entity\Entity\EntityDisplay $display
    + * @param \Drupal\Core\Entity\Display\EntityViewDisplayInterface $display
    

    Also, below:
    Interfaces++
    (Again, this is a minor fix of the previous code)

vladan.me’s picture

Trying to reroll #38

vladan.me’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work
Issue tags: -Entity Field API

The last submitted patch, field-interfaces-2031725-39.patch, failed testing.

vladan.me’s picture

Issue summary: View changes
FileSize
24.99 KB

Take 2, re-roll #38

vladan.me’s picture

Status: Needs work » Needs review
vladan.me’s picture

In DisplayOverviewBase.php instead of
+use Drupal\entity\EntityDisplayInterface;
should be probably
+use Drupal\Core\Entity\Display\EntityDisplayInterface;
Despite that, are there any other issues you see with this re-roll?

Status: Needs review » Needs work

The last submitted patch, 45: field_interfaces.patch, failed testing.

vladan.me’s picture

Status: Needs work » Needs review
FileSize
25 KB

Applying quick fix #47

tstoeckler’s picture

#41.3 and #41.4 are not adressed as far as I can see.

vladan.me’s picture

I've just done re-roll of previous patch since I was not quite sure how to implement those mentioned in #41.3 and #41.4
Can you please guide me by giving some steps of execution, what exactly needs to be done?

yched’s picture

Would be nice to update the issue with a summary with of the renames / moving around that the patch does ?

Also, minor:

+++ b/core/lib/Drupal/Core/Entity/Display/EntityDisplayInterface.php
@@ -23,7 +21,7 @@
-   * @return \Drupal\entity\Entity\EntityDisplay
+   * @return \Drupal\Core\Entity\Display\EntityDisplayInterface

@@ -56,7 +54,7 @@ public function getComponent($name);
-   * @return \Drupal\entity\Entity\EntityDisplay
+   * @return \Drupal\Core\Entity\Display\EntityDisplayInterface

@@ -67,7 +65,7 @@ public function setComponent($name, array $options = array());
-   * @return \Drupal\entity\Entity\EntityDisplay
+   * @return \Drupal\Core\Entity\Display\EntityDisplayInterface

Apparently we now can use "@return self" for those cases.

Nebel54’s picture

Rerolling #49 + inline doc update from #52. It's my first reroll… lets see if this passes…

Status: Needs review » Needs work

The last submitted patch, 53: field_interfaces-2031725-53.patch, failed testing.

fago’s picture

Status: Needs work » Needs review

Status: Needs review » Needs work

The last submitted patch, 53: field_interfaces-2031725-53.patch, failed testing.

Nebel54’s picture

Status: Needs work » Needs review
fago’s picture

Assigned: fgm » Unassigned
FileSize
47.63 KB
33.5 KB

I'm pretty sure EntityDisplay should extend EntityViewDisplayInterface and by extension, be called EntityViewDisplay.

Yep, however that would mean re-naming the whole configuration files and the config entity type.

That seems reasonable to me, but this could use it's own discussion and follow-up as it goes beyound fixing the interfaces. This goes along with that there is hook_entity_display_alter() which could deserve a rename to hook_entity_view_display_alter() also.
Thus, I left it like that for now as the class name should match the entity type name.

EntityDisplayBase can then be just EntityDisplay. Also that should directly implement ConfigEntityInterface I think.

It implements the interface already by extending the base class.

I had a closer look at the patch and noted that there were quite some uses of entity-displays without respective interfaces left, so I fixed those and re-rolled it.

The last submitted patch, 58: d8_entity_display.patch, failed testing.

fago’s picture

Title: Move all entity API related interfaces to the core component » Move all entity display interfaces to the core component
Issue summary: View changes

Adding a summary and change the title, as the patch actually just has to care about entity display interfaces.

fago’s picture

58: d8_entity_display.patch queued for re-testing.

The last submitted patch, 58: d8_entity_display.patch, failed testing.

tstoeckler’s picture

Status: Needs review » Needs work

  • The patch doesn't contain the new interfaces :-( That should explain the test fails.
  • +++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityDisplay.php
    @@ -30,7 +29,7 @@
    +class EntityDisplay extends EntityDisplayBase implements EntityDisplayInterface, ConfigEntityInterface {
    

    I'm fine with renaming EntityDisplay to EntityViewDisplay in a follow-up. This is still wrong, though: It should implement EntityViewDisplayInterface.

  • +++ b/core/modules/entity/lib/Drupal/entity/Entity/EntityFormDisplay.php
    @@ -30,7 +29,7 @@
    +class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayInterface, ConfigEntityInterface, \Serializable {
    

    This is what I meant above: Both EntityDisplay and EntityFormDisplay implement ConfigEntityInterface, so I don't see why EntityDisplayBase doesn't implement it. It's totally minor, but I don't see a reason against it.

    The actual interfaces used to extend ConfigEntityInterface, which can be seen from the patch, but they don't in the above patches (and they shouldn't!)

  • #41.3 was fixed as far as I can tell, thanks!
  • fago’s picture

    Status: Needs work » Needs review
    FileSize
    47.31 KB
    2.8 KB

    The patch doesn't contain the new interfaces :-( That should explain the test fails.

    That could be the case ;-) thanks.

    I'm fine with renaming EntityDisplay to EntityViewDisplay in a follow-up. This is still wrong, though: It should implement EntityViewDisplayInterface.

    Right, fixed that.

    Both EntityDisplay and EntityFormDisplay implement ConfigEntityInterface, so I don't see why EntityDisplayBase doesn't implement it. It's totally minor, but I don't see a reason against it.

    EntityDisplayBase extends ConfigEntityBase, thus implements the interface already. So what's wrong is that the specific class do so *again* - removed that.

    Updated patch including interfaces attached.

    amateescu’s picture

    +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockViewBuilder.php
    @@ -7,9 +7,9 @@
    +use Drupal\Core\Entity\Display\EntityViewDisplayInterface;
    

    Why are we changing the name of this interface when the name of the entity class stays the same? Can't we just move the interfaces like the issue title says and discuss whether this renaming is a good idea?

    yched’s picture

    Well, I'm not sure I see why we keep specific empty Entity(View)DisplayInterface and EntityFormDisplayInterface interfaces for the "view" and "form" flavors ?

    The design is that they work just the same with the same APIs, we could just keep the single EntityDisplayBaseInterface (and rename it to EntityDisplayInterface) ?

    amateescu’s picture

    That would be even better.

    tstoeckler’s picture

    EntityDisplayBase extends ConfigEntityBase, thus implements the interface already. So what's wrong is that the specific class do so *again* - removed that.

    I totally missed that, you are of course correct. Thanks for setting me straight.

    I disagree with removing the specialized interfaces. It's awesome that we have the generic interface which should be used in many cases. But in certain cases it's just wrong to type hint the generic interface. hook_entity_view() for example is conceptually tied to view displays. Receiving a form display there is bogus.

    amateescu’s picture

    I'm sorry but I don't see how a "combined" EntityDisplayInterface ties anything to a view or a form display.

    Both entity types (EntityDisplay and EntityFormDisplay) have the same methods and share a lot of code already through the base class..

    fago’s picture

    Issue summary: View changes
    fago’s picture

    Well, I'm not sure I see why we keep specific empty Entity(View)DisplayInterface and EntityFormDisplayInterface interfaces for the "view" and "form" flavors ?

    I'm not sure about this. True, they are all equal right now - but will it stay that way and should it? It's fine that they share the common base, but e.g. getRenderer() seems weird to me. There is no RendererInterface object or something that returns, so instead there should be getFormatter() and getWidget() methods in the respective interface. I wasn't able to find a generic use of getRenderer() either.

    The design is that they work just the same with the same APIs, we could just keep the single EntityDisplayBaseInterface (and rename it to EntityDisplayInterface

    That rename is already part of the patch, but was missing from the summary. I added it there.

    I'm sorry but I don't see how a "combined" EntityDisplayInterface ties anything to a view or a form display.

    It doesn't as long as it stays generic, but I could see the respective displays getting more helpful methods for their specific usecase. E.g. getFormatter(), getWidget() or the display object could even take over form element generation in future, i.e. receive a getFormElements() method.

    fago’s picture

    FileSize
    47.31 KB

    Re-rolled patch.

    amateescu’s picture

    I wasn't able to find a generic use of getRenderer() either.

    The use case for having a single method name for both of them (which, looking in retrospective, is pretty weak) is the Field UI base form class for the "Manage Display" and "Manage Form Display" forms, but those could just switch to use an internal helper method.

    yched’s picture

    getRenderer() seems weird to me. There is no RendererInterface object or something that returns, so instead there should be getFormatter() and getWidget() methods in the respective interface

    The intent of the generic getRenderer() is that it will return a FieldGroupRendererPlugin (or whatever field_group.module D8 will chose to call its "field groups formatter" plugins) on components that are field_groups.

    #1875974: Abstract 'component type' specific code out of EntityDisplay is all about making the "components" in EntityDisplays be of different, pluggable types - field_groups, Display suite custom fields, ...
    So, yes, that's intentional, there's no RendererInterface, what the getRenderer() method returns depends on the component type. EntityDisplay lets the ComponentHanlders generate them, and persists them throughout the multiple entity rendering.

    And so, no, there's no intention to add EntityViewDisplay::getFormatter() / EntityFormDisplay::getWidget()...

    yched’s picture

    Also:

    the display object could even take over form element generation in future, i.e. receive a getFormElements() method

    Yes, not sure we'll get there in D8, but that could totally be the case at some point - and then the ComponentHandler takes care of applying the "renderer" internally, and just return a render array.
    Still, Field UI's "Manage dispay" screens need to present a list of heterogeneous rows (fields, field groups...) and display settings form - hence the need to access a 'render plugin for the row", whatever that is.

    tstoeckler’s picture

    Re #69: I was arguing that by only having a single interface, you cannot type-hint whether you want to receive a view display or a form display in your functions. entity_view() is one case where this is weird, because it conceptually makes little sense to pass a form display.

    yched’s picture

    @tsoeckler: true - I don't see that as a big issue, but TBH I have no strong opinion.

    As long as the patch renames / gets rid of EntityDisplayBaseInterface, I'm fine with two separate interfaces. And also +1 on renaming entity_display / EntityDisplay to entity_view_display / EntityViewDisplay, here or later.

    So unless @amateescu is strongly opposed, RTBC for me.

    amateescu’s picture

    Status: Needs review » Reviewed & tested by the community

    Well, since it appears that we have an agreement on renaming EntityDisplay to EntityViewDisplay in a followup, then renaming only the interface here doesn't hurt anyone :)

    fago’s picture

    The use case for having a single method name for both of them (which, looking in retrospective, is pretty weak) is the Field UI base form class for the "Manage Display" and "Manage Form Display" forms, but those could just switch to use an internal helper method.

    Afaik, getRenderer() is only used in the view/form specific implementations.

    The intent of the generic getRenderer() is that it will return a FieldGroupRendererPlugin (or whatever field_group.module D8 will chose to call its "field groups formatter" plugins) on components that are field_groups.

    I see. So getFormatter/getWidget() would be wrong given #1875974: Abstract 'component type' specific code out of EntityDisplay - yep. Still, I don't see how I'd use a general getRenderer() method without knowing what I get there. Anyway, that's another issue so I'll stop now ;)

    tstoeckler’s picture

    +++ b/core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php
    @@ -2,16 +2,14 @@
    -interface EntityDisplayInterface extends EntityDisplayBaseInterface {
    +interface EntityFormDisplayInterface extends EntityDisplayInterface {
    
    +++ b/core/lib/Drupal/Core/Entity/Display/EntityViewDisplayInterface.php
    @@ -2,16 +2,14 @@
    -interface EntityFormDisplayInterface extends EntityDisplayBaseInterface {
    +interface EntityViewDisplayInterface extends EntityDisplayInterface {
    

    git diff is just stupid... :-)

    Looked through the patch again, and all is well. RTBC++

    fago’s picture

    72: d8_entity_display.patch queued for re-testing.

    Status: Reviewed & tested by the community » Needs work

    The last submitted patch, 72: d8_entity_display.patch, failed testing.

    fago’s picture

    Status: Needs work » Needs review
    FileSize
    48.86 KB

    Re-rolled and fixed conflicts.

    Status: Needs review » Needs work

    The last submitted patch, 83: d8_entity_display.patch, failed testing.

    vladan.me’s picture

    Status: Needs work » Needs review

    83: d8_entity_display.patch queued for re-testing.

    Status: Needs review » Needs work

    The last submitted patch, 83: d8_entity_display.patch, failed testing.

    fago’s picture

    Status: Needs work » Needs review
    FileSize
    47.37 KB
    3 KB

    Looks like Git merging messed a few hunks up - fixed those.

    fago’s picture

    Issue tags: +API change, +beta target

    This API change is required for fixing the entity module / component confusion, so let's make sure it's in before beta.

    yched’s picture

    Status: Needs review » Reviewed & tested by the community

    RTBC if green.
    Several patches are working on EntityDisplay stuff, would be good to have this cleanup first.

    alexpott’s picture

    Title: Move all entity display interfaces to the core component » Change notice: Move all entity display interfaces to the core component
    Priority: Normal » Major
    Status: Reviewed & tested by the community » Active
    Issue tags: +Approved API change, +Needs change record

    We need to ensure that any existing change notices that reference these interfaces are updated.

    Committed dd663c4 and pushed to 8.x. Thanks!

    tstoeckler’s picture

    Status: Active » Needs review

    I looked through all existing change notices that contained the word 'display' and updated some of them for the new interface name:
    https://drupal.org/node/2018597/revisions/view/2731159/6808489
    https://drupal.org/node/1907792/revisions/view/2549206/6808513
    https://drupal.org/node/1875952/revisions/view/2721457/6808523

    I'm not sure whether we need a separate change notice for this, #90 seems to imply that not to be the case.

    fago’s picture

    Title: Change notice: Move all entity display interfaces to the core component » Move all entity display interfaces to the core component
    Status: Needs review » Fixed
    Issue tags: -Needs change record

    thanks, that looks good. No, I don't think we need a separate change notice for this, thus setting to fixed.

    tstoeckler’s picture

    Status: Fixed » Closed (fixed)

    Automatically closed - issue fixed for 2 weeks with no activity.

    Berdir’s picture

    Note: #2175517: Entity displays are themselves config entities did re-add the extends ConfigEntityInterface to EntityDisplayInterface and I can see why, if you type hint on the interface, then you can not use methods from EntityInterface, which is a problem.