diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index b8de708..bd86e95 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -323,7 +323,7 @@ public function getController($entity_type, $controller_type, $controller_class_ * {@inheritdoc} */ public function getAdminRouteInfo($entity_type_id, $bundle) { - if (($entity_type = $this->getDefinition($entity_type_id, FALSE)) && $admin_form = $entity_type->getKey('field_ui_base_route')) { + if (($entity_type = $this->getDefinition($entity_type_id, FALSE)) && $admin_form = $entity_type->get('field_ui_base_route')) { return array( 'route_name' => $admin_form, 'route_parameters' => array( diff --git a/core/lib/Drupal/Core/Entity/EntityType.php b/core/lib/Drupal/Core/Entity/EntityType.php index ca24505..18036b3 100644 --- a/core/lib/Drupal/Core/Entity/EntityType.php +++ b/core/lib/Drupal/Core/Entity/EntityType.php @@ -195,6 +195,13 @@ class EntityType implements EntityTypeInterface { protected $group_label; /** + * The route name where field UI will use to attach its routes. + * + * @var string + */ + protected $field_ui_base_route; + + /** * Constructs a new EntityType. * * @param array $definition diff --git a/core/modules/field_ui/src/FieldUI.php b/core/modules/field_ui/src/FieldUI.php index 0d90e29..77ec651 100644 --- a/core/modules/field_ui/src/FieldUI.php +++ b/core/modules/field_ui/src/FieldUI.php @@ -28,7 +28,7 @@ class FieldUI { */ public static function getOverviewRouteInfo($entity_type_id, $bundle) { $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); - if ($entity_type->hasKey('field_ui_base_route')) { + if ($entity_type->get('field_ui_base_route')) { return new Url("field_ui.overview_$entity_type_id", array( $entity_type->getBundleEntityType() => $bundle, )); diff --git a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php index ba921e7..0108a3f 100644 --- a/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php +++ b/core/modules/field_ui/src/Plugin/Derivative/FieldUiLocalTask.php @@ -69,7 +69,7 @@ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = array(); foreach ($this->entityManager->getDefinitions() as $entity_type_id => $entity_type) { - if ($entity_type->isFieldable() && $entity_type->hasKey('field_ui_base_route')) { + if ($entity_type->isFieldable() && $entity_type->get('field_ui_base_route')) { $this->derivatives["overview_$entity_type_id"] = array( 'route_name' => "field_ui.overview_$entity_type_id", 'weight' => 1, @@ -172,8 +172,8 @@ public function getDerivativeDefinitions($base_plugin_definition) { */ public function alterLocalTasks(&$local_tasks) { foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { - if ($entity_info->isFieldable() && $entity_info->hasKey('field_ui_base_route')) { - $admin_form = $entity_info->getKey('field_ui_base_route'); + if ($entity_info->isFieldable() && $route_name = $entity_info->get('field_ui_base_route')) { + $admin_form = $route_name; $local_tasks["field_ui.fields:overview_$entity_type"]['base_route'] = $admin_form; $local_tasks["field_ui.fields:form_display_overview_$entity_type"]['base_route'] = $admin_form; $local_tasks["field_ui.fields:display_overview_$entity_type"]['base_route'] = $admin_form; diff --git a/core/modules/field_ui/src/Routing/RouteSubscriber.php b/core/modules/field_ui/src/Routing/RouteSubscriber.php index 01cc44c..4b371ab 100644 --- a/core/modules/field_ui/src/Routing/RouteSubscriber.php +++ b/core/modules/field_ui/src/Routing/RouteSubscriber.php @@ -41,9 +41,9 @@ public function __construct(EntityManagerInterface $manager) { protected function alterRoutes(RouteCollection $collection) { foreach ($this->manager->getDefinitions() as $entity_type_id => $entity_type) { $defaults = array(); - if ($entity_type->isFieldable() && $entity_type->hasKey('field_ui_base_route')) { + if ($entity_type->isFieldable() && $route_name = $entity_type->get('field_ui_base_route')) { // Try to get the route from the current collection. - if (!$entity_route = $collection->get($entity_type->getKey('field_ui_base_route'))) { + if (!$entity_route = $collection->get($route_name)) { continue; } $path = $entity_route->getPath(); diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php index 1c218a1..dfadfc9 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityManagerTest.php @@ -448,7 +448,7 @@ public function testGetAdminRouteInfo() { ->method('getBundleEntityType') ->will($this->returnValue('bundle')); $banana->expects($this->once()) - ->method('getKey') + ->method('get') ->with('field_ui_base_route') ->will($this->returnValue('entity.view')); $this->setUpEntityManager(array(