diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index f680466..18ae281 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -1024,16 +1024,16 @@ protected function getDisplayModeOptions($display_type, $entity_type_id) { } /** - * Returns an array of display mode options for a certain bundle. + * Returns an array of display mode options by bundle. * * @param $display_type - * The display type to be retrieved. It can be "view_mode" or "form_mode". + * The display type to be retrieved. It can be "view_mode" or "form_mode". * @param string $entity_type_id * The entity type whose display mode options should be returned. * @param string $bundle * The name of the bundle. * @param bool $include_disabled - * Force to include disabled view modes. Defaults to FALSE. + * Include disabled display modes. Defaults to FALSE. * * @return array * An array of display mode labels, keyed by the display mode ID. @@ -1048,16 +1048,16 @@ protected function getDisplayModeOptionsByBundle($display_type, $entity_type_id, // Load all the entity's display modes. $display_modes = $this->getDisplayModesByEntityType($display_type, $entity_type_id); - // Get the list of available display modes for the current block's bundle. + // Get the list of available entity displays for the current bundle. $ids = $this->configFactory->listAll($config_prefix . '.' . $entity_type_id . '.' . $bundle); foreach ($ids as $id) { $load_ids[] = str_replace($config_prefix . '.', '', $id); } // Generate the display options array. - $displays = entity_load_multiple($display_type_entity_name, $load_ids); - foreach ($displays as $display) { - if ($display->status() || $include_disabled) { + $entity_displays = entity_load_multiple($display_type_entity_name, $load_ids); + foreach ($entity_displays as $display) { + if ($display->status() || $include_disabled || $display->id() == 'default') { $display_mode_name = $display->get('mode'); $display_mode_options[$display_mode_name] = ($display_mode_name == 'default') ? t('Default') : $display_modes[$display_mode_name]['label']; } diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index 13bbb9a..98b13b7 100644 --- a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php @@ -456,7 +456,7 @@ public function getFormModeOptions($entity_type_id); * @param string $bundle * The name of the bundle. * @param bool $include_disabled - * Force to include disabled view modes. Defaults to FALSE. + * Include disabled view modes. Defaults to FALSE. * * @return array * An array of view mode labels, keyed by the display mode ID. @@ -471,7 +471,7 @@ public function getViewModeOptionsByBundle($entity_type_id, $bundle, $include_di * @param string $bundle * The name of the bundle. * @param bool $include_disabled - * Force to include disabled form modes. Defaults to FALSE. + * Include disabled form modes. Defaults to FALSE. * * @return array * An array of form mode labels, keyed by the display mode ID. diff --git a/core/modules/block_content/src/Tests/BlockContentCreationTest.php b/core/modules/block_content/src/Tests/BlockContentCreationTest.php index 8f8b240..d6af327 100644 --- a/core/modules/block_content/src/Tests/BlockContentCreationTest.php +++ b/core/modules/block_content/src/Tests/BlockContentCreationTest.php @@ -134,19 +134,16 @@ public function testBlockContentCreationMultipleViewModes() { $view_mode['settings[view_mode]'] = 'test_view_mode'; $this->drupalPostForm(NULL, $view_mode, t('Save block')); - // Load the block. - $this->drupalGet('admin/structure/block/manage/testblock'); - // Check that the view mode setting is shown because more than one exists. + $this->drupalGet('admin/structure/block/manage/testblock'); $this->assertFieldByXPath('//select[@name="settings[view_mode]"]', NULL, 'View mode setting shown because multiple exist'); // Change the view mode. $view_mode['settings[view_mode]'] = 'test_view_mode'; $this->drupalPostForm(NULL, $view_mode, t('Save block')); - // Load the block. + // Go to the configure page and verify the view mode has changed. $this->drupalGet('admin/structure/block/manage/testblock'); - $this->assertFieldByXPath('//select[@name="settings[view_mode]"]/option[@selected="selected"]/@value', 'test_view_mode', 'View mode changed to Test View Mode'); // Check that the block exists in the database.