Revert "Issue #2809527 by tim.plunkett, Berdir: Add backwards compatibility layer for entity display default config that lacks 'region'"
This reverts commit dd6d586818
.
8.3.x
parent
ee3544faf3
commit
4c68d20583
|
@ -245,17 +245,6 @@ abstract class EntityDisplayBase extends ConfigEntityBase implements EntityDispl
|
|||
* {@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());
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
<?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']);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue