From c4fe19b5d6fc226ad9dba8fe2f374efec21341f7 Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Fri, 17 Nov 2017 10:37:52 +0100 Subject: [PATCH] interdiff --- core/modules/field_ui/field_ui.module | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index 272353f..c90fa60 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -10,7 +10,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Entity\EntityViewModeInterface; use Drupal\Core\Entity\EntityFormModeInterface; -use Drupal\Core\Url; +use Drupal\Core\Routing\RouteProviderLazyBuilder; use Drupal\field_ui\FieldUI; use Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask; @@ -109,6 +109,22 @@ function field_ui_entity_type_build(array &$entity_types) { * Implements hook_entity_type_alter(). */ function field_ui_entity_type_alter(array &$entity_types) { + // Because we are in the middle of building entity type definitions and we + // need information from another "build system" (routes), we need to build in + // an eternal loop prevention. Otherwise, if the route builder needs info + // about entity types, it will trigger yet another entity type build and we + // will keep looping back and forth between the two systems. + // + // Something like this is currently possible because Views' route subscriber. + // @see https://www.drupal.org/project/drupal/issues/2924075 + // + // @todo Remove when the above issue has a fix. + $building = &drupal_static(__FUNCTION__, FALSE); + if ($building) { + return; + } + $building = TRUE; + /** @var \Drupal\Core\Routing\RouteProvider $route_provider */ $route_provider = \Drupal::service('router.route_provider'); @@ -117,12 +133,14 @@ function field_ui_entity_type_alter(array &$entity_types) { // Add manage fields and display link relations and templates if this entity // type is the bundle of another and that type has field UI enabled. if (($bundle_of = $entity_type->getBundleOf()) && ($base_route = $entity_types[$bundle_of]->get('field_ui_base_route'))) { - $field_ui_path = $route_provider->getRouteByName($base_route)->getPath() . '/fields'; - $entity_type->setLinkTemplate('drupal:field-ui-fields', $field_ui_path); + $field_ui_path = $route_provider->getRouteByName($base_route)->getPath(); + $entity_type->setLinkTemplate('drupal:field-ui-fields', $field_ui_path . '/fields'); $entity_type->setLinkTemplate('drupal:field-ui-form-display', $field_ui_path . '/form-display'); $entity_type->setLinkTemplate('drupal:field-ui-display', $field_ui_path . '/display'); } } + + $building = FALSE; } /** -- 2.8.1