Problem/Motivation

The goal of #2844302: Move Field Layout data model and API directly into \Drupal\Core\Entity\EntityDisplayBase is to move the functionality of Field Layout directly into the EntityDisplay system and Field UI.

In order to accomplish that move, several changes must be made to existing core code, this is one of them.


Layout regions are defined by the layout definition, and should be rendered on the page in that order.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tim.plunkett created an issue. See original summary.

tim.plunkett’s picture

The last submitted patch, 2: 2851648-layoutregions-2-FAIL.patch, failed testing.

jibran’s picture

+++ b/core/lib/Drupal/Core/Layout/LayoutDefault.php
@@ -34,7 +34,13 @@ public function __construct(array $configuration, $plugin_id, $plugin_definition
+    foreach ($this->getPluginDefinition()->getRegionNames() as $region) {

Let's call it $region_name. It helps in avoiding the confusion between $region and $regions.

tim.plunkett’s picture

jibran’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

  • xjm committed fee5c76 on 8.4.x
    Issue #2851648 by tim.plunkett, jibran: Layout regions should be in the...

  • xjm committed 5dc0e21 on 8.3.x
    Issue #2851648 by tim.plunkett, jibran: Layout regions should be in the...
xjm’s picture

Version: 8.4.x-dev » 8.3.x-dev
Status: Reviewed & tested by the community » Fixed

OK.

The number of regions should not be large enough that which way it is sorted matters, although since these are render arrays the child elements could get quite massive. But the render system has to do orders more manipulation that that, and after all that's what render caching is for. Would be premature optimization to worry about that more here, I think.

It's tested. Expected ordering of things is good. I asked @tim.plunkett about config sorting but he pointed out that the only configurable core implementation yet just adds a single region as one configured property of each field, so the sorting of the regions is not applicable to that.

Since this is an alpha experimental module, this change is eligible for 8.3.x. Committed to 8.4.x and 8.3.x. Thanks!

tim.plunkett’s picture

For the record, this works instead of the foreach, but I found it incomprehensible:

$defined_regions = array_fill_keys($this->getPluginDefinition()->getRegionNames(), []);
$build = array_filter(array_intersect_key(array_replace($defined_regions, $regions), $defined_regions));

Status: Fixed » Closed (fixed)

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