diff --git a/core/includes/entity.inc b/core/includes/entity.inc index 42c7279..ff72cf2 100644 --- a/core/includes/entity.inc +++ b/core/includes/entity.inc @@ -727,18 +727,19 @@ function entity_get_display($entity_type, $bundle, $view_mode) { function entity_get_render_display(EntityInterface $entity, $view_mode) { $entity_type = $entity->entityType(); $bundle = $entity->bundle(); - - // Determine the display to use for rendering this entity display. We load - // the default and the view mode that is passed in. Depending on the status - // of the view mode entity display, we fall back on default. $render_view_mode = 'default'; - $load = array( - $entity->entityType() . '.' . $entity->bundle() . '.default', - $entity->entityType() . '.' . $entity->bundle() . '.' . $view_mode, - ); - $entity_displays = entity_load_multiple('entity_display', $load); - if (isset($entity_displays[$entity->entityType() . '.' . $entity->bundle() . '.' . $view_mode]) && $entity_displays[$entity->entityType() . '.' . $entity->bundle() . '.' . $view_mode]->status) { - $render_view_mode = $view_mode; + + // Look at the default display and display for the view mode, and fallback to + // the former if the latter does not exist is disabled. + if ($view_mode != 'default') { + $ids = array( + 'entity.display.' . $entity->entityType() . '.' . $entity->bundle() . '.default', + 'entity.display.' . $entity->entityType() . '.' . $entity->bundle() . '.' . $view_mode, + ); + $entity_displays = \Drupal::service('config.storage')->readMultiple($ids); + if (isset($entity_displays[$ids[1]]) && $entity_displays[$ids[1]]['status']) { + $render_view_mode = $view_mode; + } } $display = entity_get_display($entity_type, $bundle, $render_view_mode); @@ -826,18 +827,19 @@ function entity_get_form_display($entity_type, $bundle, $form_mode) { function entity_get_render_form_display(EntityInterface $entity, $form_mode) { $entity_type = $entity->entityType(); $bundle = $entity->bundle(); - - // Determine the display to use for rendering this form display. We load - // the default and the form mode that is passed in. Depending on the status - // of the form mode entity display, we fall back on default. $render_form_mode = 'default'; - $load = array( - $entity->entityType() . '.' . $entity->bundle() . '.default', - $entity->entityType() . '.' . $entity->bundle() . '.' . $form_mode, - ); - $entity_form_displays = entity_load_multiple('entity_form_display', $load); - if (isset($entity_form_displays[$entity->entityType() . '.' . $entity->bundle() . '.' . $form_mode]) && $entity_form_displays[$entity->entityType() . '.' . $entity->bundle() . '.' . $form_mode]->status) { - $render_form_mode = $form_mode; + + // Look at the default form display and form display for the view mode, and + // fallback to the former if the latter does not exist is disabled. + if ($form_mode != 'default') { + $ids = array( + 'entity.form_display.' . $entity->entityType() . '.' . $entity->bundle() . '.default', + 'entity.form_display.' . $entity->entityType() . '.' . $entity->bundle() . '.' . $form_mode, + ); + $entity_form_displays = \Drupal::service('config.storage')->readMultiple($ids); + if (isset($entity_form_displays[$ids[1]]) && $entity_form_displays[$ids[1]]['status']) { + $render_form_mode = $form_mode; + } } $form_display = entity_get_form_display($entity_type, $bundle, $render_form_mode); diff --git a/core/modules/entity/entity.install b/core/modules/entity/entity.install index 576ebed..d9f2c3e 100644 --- a/core/modules/entity/entity.install +++ b/core/modules/entity/entity.install @@ -20,7 +20,7 @@ * @param string $view_mode * The view mode. + * @param string $status -+ * The status of the display. ++ * The boolean of the display. * * @return \Drupal\Core\Config\Config * The configuration object. @@ -61,7 +61,7 @@ function _update_8000_entity_get_display($entity_type, $bundle, $view_mode, $sta * The bundle name. * @param string $form_mode * The form mode. -+ * @param string $status ++ * @param boolean $status + * The status of the form display. * * @return \Drupal\Core\Config\Config diff --git a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php index 1e13d59..1147e6a 100644 --- a/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php +++ b/core/modules/entity/lib/Drupal/entity/EntityDisplayBase.php @@ -51,7 +51,8 @@ public $mode; /** - * Whether this display is enabled or not. + * Whether this display is enabled or not. If the entity (form) display + * is disabled, we'll fall back to the 'default' display. * * @var boolean */ diff --git a/core/modules/field/field.install b/core/modules/field/field.install index a139367..fac46a3 100644 --- a/core/modules/field/field.install +++ b/core/modules/field/field.install @@ -262,9 +262,10 @@ function field_update_8002() { if (isset($variable_value['extra_fields']['display'])) { foreach ($variable_value['extra_fields']['display'] as $field_name => $field_settings) { foreach ($field_settings as $view_mode => $display_options) { - // Determine name and create initial entry in the $displays array - // if it does not exist yet. - $display_id = $entity_type . '.' . $bundle . '.' . $view_mode; if (!isset($displays[$display_id])) { + // Determine name and create initial entry in the $displays array + // if it does not exist yet. + $display_id = $entity_type . '.' . $bundle . '.' . $view_mode; + if (!isset($displays[$display_id])) { $displays[$display_id] = _update_8000_entity_get_display($entity_type, $bundle, $view_mode); } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php b/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php index 51e1892..f753a6a 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Access/FormModeAccessCheck.php @@ -31,12 +31,14 @@ public function access(Route $route, Request $request) { $bundle = $request->attributes->get('bundle'); $form_mode = $request->attributes->get('mode'); - $visibility = ($form_mode == 'default') ? TRUE : FALSE; - if ($form_mode != 'default') { - $entity_form_display = entity_load('entity_form_display', $entity_type . '.' . $bundle . '.' . $form_mode); - if ($entity_form_display) { - $visibility = $entity_form_display->status; - } + if ($form_mode == 'default') { + $visibility = TRUE; + } + elseif ($entity_form_display = entity_load('entity_form_display', $entity_type . '.' . $bundle . '.' . $form_mode)) { + $visibility = $entity_form_display->status; + } + else { + $visibility = FALSE; } if ($visibility) { diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php b/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php index 04ba18b..e930ec1 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Access/ViewModeAccessCheck.php @@ -31,12 +31,14 @@ public function access(Route $route, Request $request) { $bundle = $request->attributes->get('bundle'); $view_mode = $request->attributes->get('mode'); - $visibility = ($view_mode == 'default') ? TRUE : FALSE; - if ($view_mode != 'default') { - $entity_display = entity_load('entity_display', $entity_type . '.' . $bundle . '.' . $view_mode); - if ($entity_display) { - $visibility = $entity_display->status; - } + if ($view_mode == 'default') { + $visibility = TRUE; + } + elseif ($entity_display = entity_load('entity_display', $entity_type . '.' . $bundle . '.' . $view_mode)) { + $visibility = $entity_display->status; + } + else { + $visibility = FALSE; } if ($visibility) {