Commit 4c68d205 authored by catch's avatar catch

Revert "Issue #2809527 by tim.plunkett, Berdir: Add backwards compatibility...

Revert "Issue #2809527 by tim.plunkett, Berdir: Add backwards compatibility layer for entity display default config that lacks 'region'"

This reverts commit dd6d5868.
parent ee3544fa
......@@ -245,17 +245,6 @@ public function id() {
* {@inheritdoc}
*/
public function preSave(EntityStorageInterface $storage, $update = TRUE) {
// @todo For backwards compatibility, ensure that each component is properly
// updated. Remove this in https://www.drupal.org/node/2799641.
foreach ($this->getComponents() as $name => $component) {
// Ensure that a region is set.
// @todo Make 'region' required in https://www.drupal.org/node/2799641.
if (!isset($component['region'])) {
// Directly set the component to bypass other changes in setComponent().
$this->content[$name]['region'] = (isset($component['type']) && $component['type'] === 'hidden') ? 'hidden' : $this->getDefaultRegion();
}
}
ksort($this->content);
ksort($this->hidden);
parent::preSave($storage, $update);
......
......@@ -51,7 +51,10 @@ function system_post_update_recalculate_configuration_entity_dependencies(&$sand
*/
function system_post_update_add_region_to_entity_displays() {
$entity_save = function (EntityDisplayInterface $entity) {
// preSave() will fill in the correct region based on the 'type'.
foreach ($entity->getComponents() as $name => $component) {
// setComponent() will fill in the correct region based on the 'type'.
$entity->setComponent($name, $component);
}
$entity->save();
};
array_map($entity_save, EntityViewDisplay::loadMultiple());
......
<?php
namespace Drupal\KernelTests\Core\Entity;
use Drupal\Core\Entity\Entity\EntityViewDisplay;
use Drupal\KernelTests\KernelTestBase;
/**
* @coversDefaultClass \Drupal\Core\Entity\EntityDisplayBase
*
* @group Entity
*/
class EntityDisplayBaseTest extends KernelTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['entity_test'];
/**
* @covers ::preSave
*/
public function testPreSave() {
$entity_display = EntityViewDisplay::create([
'targetEntityType' => 'entity_test',
'bundle' => 'entity_test',
'mode' => 'default',
'status' => TRUE,
'content' => ['foo' => ['type' => 'visible']],
]);
// Ensure that no region is set on the component.
$component = $entity_display->getComponent('foo');
$this->assertArrayNotHasKey('region', $component);
// Ensure that a region is set on the component after saving.
$entity_display->save();
$component = $entity_display->getComponent('foo');
$this->assertArrayHasKey('region', $component);
$this->assertSame('content', $component['region']);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment