diff --git a/core/modules/field_layout/src/Entity/FieldLayoutEntityFormDisplay.php b/core/modules/field_layout/src/Entity/FieldLayoutEntityFormDisplay.php index 87e271f..a694b10 100644 --- a/core/modules/field_layout/src/Entity/FieldLayoutEntityFormDisplay.php +++ b/core/modules/field_layout/src/Entity/FieldLayoutEntityFormDisplay.php @@ -19,7 +19,7 @@ class FieldLayoutEntityFormDisplay extends EntityFormDisplay implements EntityDi * which is fixed in PHP 7.0.6. */ public function getDefaultRegion() { - $layout_definition = \Drupal::service('field_layout.layout_repository')->getLayout($this->getLayoutId()); + $layout_definition = \Drupal::service('field_layout.layout_repository')->getLayout($this->getLayoutId() ?: 'default'); return isset($layout_definition['default_region']) ? $layout_definition['default_region'] : key($layout_definition['regions']); } diff --git a/core/modules/field_layout/src/Entity/FieldLayoutEntityViewDisplay.php b/core/modules/field_layout/src/Entity/FieldLayoutEntityViewDisplay.php index 2ae6088..07ecbcb 100644 --- a/core/modules/field_layout/src/Entity/FieldLayoutEntityViewDisplay.php +++ b/core/modules/field_layout/src/Entity/FieldLayoutEntityViewDisplay.php @@ -19,7 +19,7 @@ class FieldLayoutEntityViewDisplay extends EntityViewDisplay implements EntityDi * which is fixed in PHP 7.0.6. */ public function getDefaultRegion() { - $layout_definition = \Drupal::service('field_layout.layout_repository')->getLayout($this->getLayoutId()); + $layout_definition = \Drupal::service('field_layout.layout_repository')->getLayout($this->getLayoutId() ?: 'default'); return isset($layout_definition['default_region']) ? $layout_definition['default_region'] : key($layout_definition['regions']); } diff --git a/core/modules/field_layout/src/Form/FieldLayoutEntityDisplayFormTrait.php b/core/modules/field_layout/src/Form/FieldLayoutEntityDisplayFormTrait.php index ac2ae1e..6285bd3 100644 --- a/core/modules/field_layout/src/Form/FieldLayoutEntityDisplayFormTrait.php +++ b/core/modules/field_layout/src/Form/FieldLayoutEntityDisplayFormTrait.php @@ -24,7 +24,7 @@ public function getRegions() { $regions = []; - $layout = $this->fieldLayoutRepository->getLayout($this->getEntity()->getLayoutId()); + $layout = $this->fieldLayoutRepository->getLayout($this->getEntity()->getLayoutId() ?: 'default'); foreach ($layout['regions'] as $name => $region) { $regions[$name] = [ 'title' => $region['label'], diff --git a/core/modules/field_layout/src/LayoutRepository.php b/core/modules/field_layout/src/LayoutRepository.php index 0ed8e93..4ae3b25 100644 --- a/core/modules/field_layout/src/LayoutRepository.php +++ b/core/modules/field_layout/src/LayoutRepository.php @@ -130,7 +130,6 @@ protected function processDefinition(&$definition, $plugin_id) { * {@inheritdoc} */ public function getLayout($layout_id) { - $layout_id = $layout_id ?: 'default'; $layout_definitions = $this->getDefinitions(); if (!$layout_id || !isset($layout_definitions[$layout_id])) { return []; diff --git a/core/modules/field_layout/src/LayoutRepositoryInterface.php b/core/modules/field_layout/src/LayoutRepositoryInterface.php index c6862f8..70badb9 100644 --- a/core/modules/field_layout/src/LayoutRepositoryInterface.php +++ b/core/modules/field_layout/src/LayoutRepositoryInterface.php @@ -28,8 +28,8 @@ public function getGroupedDefinitions(array $definitions = NULL); /** * Gets the layout definition for a given layout ID. * - * @param string|null $layout_id - * The layout ID. If NULL, a default will be provided. + * @param string $layout_id + * The layout ID. * * @return mixed[] * The layout definition for the given display. diff --git a/core/modules/field_layout/tests/src/Unit/LayoutRepositoryTest.php b/core/modules/field_layout/tests/src/Unit/LayoutRepositoryTest.php index 9b7ce5a..1dd4212 100644 --- a/core/modules/field_layout/tests/src/Unit/LayoutRepositoryTest.php +++ b/core/modules/field_layout/tests/src/Unit/LayoutRepositoryTest.php @@ -83,28 +83,4 @@ public function testGetLayout() { $this->assertEquals($expected, $layout_definition); } - /** - * @covers ::getLayout - */ - public function testGetLayoutEmpty() { - $expected = [ - 'label' => 'Default', - 'theme' => 'field_layout__default', - 'provider' => 'field_layout', - 'category' => 'Columns: 1', - 'default_region' => 'content', - 'regions' => [ - 'content' => [ - 'label' => 'Content', - ], - ], - 'path' => NULL, - 'template' => 'field-layout--default', - 'layout' => 'default', - 'provider_type' => 'module', - ]; - $layout_definition = $this->layoutRepository->getLayout(NULL); - $this->assertEquals($expected, $layout_definition); - } - }