diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index e4e0f8d..69d70ef 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -1102,15 +1102,15 @@ public function getFormModeOptions($entity_type_id) { /** * {@inheritdoc} */ - public function getViewModeOptionsByBundle($entity_type_id, $bundle) { - return $this->getDisplayModeOptionsByBundle('view_mode', $entity_type_id, $bundle); + public function getEnabledViewModeOptionsByBundle($entity_type_id, $bundle) { + return $this->getEnabledDisplayModeOptionsByBundle('view_mode', $entity_type_id, $bundle); } /** * {@inheritdoc} */ - public function getFormModeOptionsByBundle($entity_type_id, $bundle) { - return $this->getDisplayModeOptionsByBundle('form_mode', $entity_type_id, $bundle); + public function getEnabledFormModeOptionsByBundle($entity_type_id, $bundle) { + return $this->getEnabledDisplayModeOptionsByBundle('form_mode', $entity_type_id, $bundle); } /** @@ -1133,7 +1133,7 @@ protected function getDisplayModeOptions($display_type, $entity_type_id) { } /** - * Returns an array of display mode options by bundle. + * Returns an array of enabled display mode options by bundle. * * @param $display_type * The display type to be retrieved. It can be "view_mode" or "form_mode". @@ -1145,7 +1145,7 @@ protected function getDisplayModeOptions($display_type, $entity_type_id) { * @return array * An array of display mode labels, keyed by the display mode ID. */ - protected function getDisplayModeOptionsByBundle($display_type, $entity_type_id, $bundle) { + protected function getEnabledDisplayModeOptionsByBundle($display_type, $entity_type_id, $bundle) { // Collect all the entity's display modes. $options = $this->getDisplayModeOptions($display_type, $entity_type_id); diff --git a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php index fad1092..1ed3333 100644 --- a/core/lib/Drupal/Core/Entity/EntityManagerInterface.php +++ b/core/lib/Drupal/Core/Entity/EntityManagerInterface.php @@ -450,7 +450,7 @@ public function getViewModeOptions($entity_type_id); public function getFormModeOptions($entity_type_id); /** - * Returns an array of view mode options by bundle. + * Returns an array of enabled view mode options by bundle. * * @param string $entity_type_id * The entity type whose view mode options should be returned. @@ -460,10 +460,10 @@ public function getFormModeOptions($entity_type_id); * @return array * An array of view mode labels, keyed by the display mode ID. */ - public function getViewModeOptionsByBundle($entity_type_id, $bundle); + public function getEnabledViewModeOptionsByBundle($entity_type_id, $bundle); /** - * Returns an array of form mode options by bundle. + * Returns an array of enabled form mode options by bundle. * * @param string $entity_type_id * The entity type whose form mode options should be returned. @@ -473,7 +473,7 @@ public function getViewModeOptionsByBundle($entity_type_id, $bundle); * @return array * An array of form mode labels, keyed by the display mode ID. */ - public function getFormModeOptionsByBundle($entity_type_id, $bundle); + public function getEnabledFormModeOptionsByBundle($entity_type_id, $bundle); /** * Loads an entity by UUID. diff --git a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php index 143a20d..208bd52 100644 --- a/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php +++ b/core/modules/block_content/src/Plugin/Block/BlockContentBlock.php @@ -117,7 +117,7 @@ public function defaultConfiguration() { public function blockForm($form, FormStateInterface $form_state) { $uuid = $this->getDerivativeId(); $block = $this->entityManager->loadEntityByUuid('block_content', $uuid); - $options = $this->entityManager->getViewModeOptionsByBundle('block_content', $block->bundle()); + $options = $this->entityManager->getEnabledViewModeOptionsByBundle('block_content', $block->bundle()); $form['view_mode'] = array( '#type' => 'select', diff --git a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php index cb72e95..299d5a0 100644 --- a/core/modules/field_ui/src/Form/EntityDisplayFormBase.php +++ b/core/modules/field_ui/src/Form/EntityDisplayFormBase.php @@ -211,8 +211,8 @@ public function form(array $form, FormStateInterface $form_state) { ); // Prepare default values for the 'Custom display settings' checkboxes. $default = array(); - if ($display_statuses = array_filter($this->getDisplayStatuses())) { - $default = array_keys(array_intersect_key($display_mode_options, $display_statuses)); + if ($enabled_displays = array_filter($this->getDisplayStatuses())) { + $default = array_keys(array_intersect_key($display_mode_options, $enabled_displays)); } $form['modes']['display_modes_custom'] = array( '#type' => 'checkboxes', diff --git a/core/modules/field_ui/src/Tests/EntityDisplayTest.php b/core/modules/field_ui/src/Tests/EntityDisplayTest.php index 376e096..6077c99 100644 --- a/core/modules/field_ui/src/Tests/EntityDisplayTest.php +++ b/core/modules/field_ui/src/Tests/EntityDisplayTest.php @@ -490,17 +490,17 @@ public function testGetDisplayModeOptions() { $form_display_teaser->save(); // Test getViewModeOptionsByBundle(). - $view_modes = \Drupal::entityManager()->getViewModeOptionsByBundle('node', 'article'); + $view_modes = \Drupal::entityManager()->getEnabledViewModeOptionsByBundle('node', 'article'); $this->assertEqual($view_modes, array('default' => 'Default')); $display_teaser->setStatus(TRUE)->save(); - $view_modes = \Drupal::entityManager()->getViewModeOptionsByBundle('node', 'article'); + $view_modes = \Drupal::entityManager()->getEnabledViewModeOptionsByBundle('node', 'article'); $this->assertEqual($view_modes, array('default' => 'Default', 'teaser' => 'Teaser')); // Test getFormModeOptionsByBundle(). - $form_modes = \Drupal::entityManager()->getFormModeOptionsByBundle('user', 'user'); + $form_modes = \Drupal::entityManager()->getEnabledFormModeOptionsByBundle('user', 'user'); $this->assertEqual($form_modes, array('default' => 'Default')); $form_display_teaser->setStatus(TRUE)->save(); - $form_modes = \Drupal::entityManager()->getFormModeOptionsByBundle('user', 'user'); + $form_modes = \Drupal::entityManager()->getEnabledFormModeOptionsByBundle('user', 'user'); $this->assertEqual($form_modes, array('default' => 'Default', 'register' => 'Register')); } diff --git a/core/modules/node/src/Form/NodePreviewForm.php b/core/modules/node/src/Form/NodePreviewForm.php index a126c9e..4672529 100644 --- a/core/modules/node/src/Form/NodePreviewForm.php +++ b/core/modules/node/src/Form/NodePreviewForm.php @@ -86,7 +86,7 @@ public function buildForm(array $form, FormStateInterface $form_state, EntityInt '#options' => array('attributes' => array('class' => array('node-preview-backlink'))) + $query_options, ); - $view_mode_options = $this->entityManager->getViewModeOptionsByBundle('node', $node->bundle()); + $view_mode_options = $this->entityManager->getEnabledViewModeOptionsByBundle('node', $node->bundle()); // Unset view modes that are not used in the front end. unset($view_mode_options['rss']);