Follow-up from #1976158: Rename entity storage/list/form/render "controllers" to handlers.

Including:
- Base class and interface
- All subclasses
- Document references
- EntityManager methods,
- render => view_builder
- entity_render_controller() (not used anymore, should we drop it?)
- variable and property names
- Killed EntityTestRender and moved view_builder to EntityTest. No need for a separate entity type IMHO and we ended up with the same name for the entity type and the view builder when renaming it.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Berdir’s picture

Status: Active » Needs review
FileSize
74.51 KB

Here's the patch, let's see how good my search & replaces are.

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-1.patch, failed testing.

joachim’s picture

Isn't there a risk that 'view_builder' will be confused with Views? That's what I first thought of when I read the name...

Berdir’s picture

Status: Needs work » Needs review
FileSize
297 bytes
74.66 KB

@joachim: We discussed this issue for more than an hour. That point came up, but node_view(), user_view() and similar functions have existed since forever, so I don't think it's a problem.

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-4.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
87.23 KB

Just a re-roll for now.

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-6.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
102.85 KB

Fixed the left-over merge conflict in that file.

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-8.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
4.81 KB
89.38 KB

Ah, found it, nasty one. The derivate still looked for the render controller but that doesn't exist anymore to generate the entity row plugins, so they didn't exist anymore but node altered it and that resulted in an incomplete definition.

Let's see what the real remaining fails are.

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-10.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
889 bytes
89.38 KB

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-12.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
16.5 KB
98.97 KB

Fixed a lot of tests, some pretty well hidden references to the render controller... Especially those that don't go through hasController() really should be updated. but for now, simple string replacements...

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-14.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
7.14 KB
100.92 KB

Innnteresting side effects of the entity_test changes. Will explain the changes in the next comment.

Berdir’s picture

  1. +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityUriTest.php
    @@ -30,10 +30,10 @@ public function setUp() {
    -    $entity = entity_create('entity_test', array('name' => 'test', 'user_id' => 1));
    +    $entity = entity_create('entity_test_no_label', array('name' => 'test', 'user_id' => 1));
         $entity->save();
         $uri = $entity->uri();
    -    $expected_path = 'entity/entity_test/' . $entity->id();
    +    $expected_path = 'entity/entity_test_no_label/' . $entity->id();
    

    entity_test now has a uri on it's own, so we need to switch to one that doesn't.

  2. +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php
    @@ -73,17 +73,7 @@ function testEntityViewController() {
    -    // Create a text field which will be rendered with custom item attributes.
    -    entity_create('field_entity', array(
    -      'name' => 'field_test_text',
    -      'entity_type' => 'entity_test',
    -      'type' => 'text',
    -    ))->save();
    -    entity_create('field_instance', array(
    -      'entity_type' => 'entity_test',
    -      'field_name' => 'field_test_text',
    -      'bundle' => 'entity_test',
    -    ))->save();
    +    // Make sure the test field will be rendered.
         entity_get_display('entity_test', 'entity_test', 'default')
           ->setComponent('field_test_text', array('type' => 'text_default'))
           ->save();
    

    entity_test already gets the field_test_text field by default so we don't need to create it, *but* it doesn't get the display configuration.

  3. +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityViewControllerTest.php
    @@ -111,6 +101,7 @@ public function testFieldItemAttributes() {
         // Browse to the entity and verify that the attributes from both modules
         // are rendered in the field item HTML markup.
    +    \Drupal::entityManager()->getViewBuilder('entity_test')->resetCache(array($entity->id()));
         $this->drupalGet('entity_test/' . $entity->id());
    

    entity_test apparently also has the render cache enabled, entity_render_test did not?

  4. +++ b/core/modules/system/tests/modules/entity_test/entity_test.module
    @@ -527,7 +527,7 @@ function entity_test_entity_prepare_view($entity_type, array $entities, array $d
    -      if ($entity->getPropertyDefinition('field_test_text')) {
    +      if ($entity->getPropertyDefinition('field_test_text') && $displays[$entity->bundle()]->getComponent('field_test_text')) {
             foreach ($entity->get('field_test_text') as $item) {
               $item->_attributes += array('data-field-item-attr' => 'foobar');
             }
    

    This is consistent with the rdf implementation, only add the attributes if the field_test_text has a display component. Doesn't by default. One of the many problems in CommentNonNodeTest.

  5. +++ b/core/modules/views/lib/Drupal/views/Tests/QueryGroupByTest.php
    @@ -24,7 +24,7 @@ class QueryGroupByTest extends ViewUnitTestBase {
    -  public static $modules = array('entity_test', 'system', 'field');
    +  public static $modules = array('entity', 'entity_test', 'system', 'field');
    

    saving an entity_test entity now results in the entity render cache getting cleared, the process of that instantiates a view builder, which in turn loads the view modes of that entity type. They are defined in entity.module.

Berdir’s picture

Status: Needs review » Needs work
Issue tags: +Needs issue summary update, +API change, +Approved API change

The last submitted patch, view-builder-2097903-16.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
100.95 KB

Re-roll.

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-20.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
101.75 KB
688 bytes

Another re-roll and fixed a new call to getRenderController().

Status: Needs review » Needs work

The last submitted patch, view-builder-2097903-22.patch, failed testing.

Berdir’s picture

Status: Needs work » Needs review
FileSize
1.04 KB
102.47 KB

Fixing that test.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Looks good to me.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs reroll

Patch no longer applies.

amateescu’s picture

Status: Needs work » Reviewed & tested by the community
Issue tags: -Needs reroll
FileSize
102.46 KB

Rerolled.

alexpott’s picture

Status: Reviewed & tested by the community » Needs work

entity_test_render is still used in \Drupal\entity_test\Plugin\Derivative\EntityTestLocalTasks and \Drupal\entity_test\Routing\RouteSubscriber - I think we need to remove this.

Berdir’s picture

Status: Needs work » Needs review
FileSize
1.55 KB
104.03 KB

True, removed those two lines. The first one is from today I think and the other didn't cause any failures because the routes were defined but nothing used them.

amateescu’s picture

Status: Needs review » Reviewed & tested by the community

Grepped the codebase and there's no trace of entity_test_render anymore, so back to RTBC.

alexpott’s picture

Title: Rename EntityRenderController to EntityViewBuilder » Change notice: Rename EntityRenderController to EntityViewBuilder
Priority: Normal » Major
Status: Reviewed & tested by the community » Active
Issue tags: +Needs change record

Committed 4b7bbec and pushed to 8.x. Thanks!

Berdir’s picture

Title: Change notice: Rename EntityRenderController to EntityViewBuilder » Rename EntityRenderController to EntityViewBuilder
Status: Active » Fixed

Updated https://drupal.org/node/1819308/revisions/view/2667818/2891523.

I guess we'll create a new change notice for changing controller to something else in the main issue. I also prepared https://drupal.org/developing/api/entity to document the view builder.

Berdir’s picture

Removing tags.

Status: Fixed » Closed (fixed)

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