From 4be5c5bd9bad57909877a5a30f5e8fba5e71535a Mon Sep 17 00:00:00 2001 From: Kristiaan Van den Eynde Date: Fri, 21 Sep 2018 14:26:36 +0200 Subject: [PATCH] interdiff --- core/modules/field_ui/field_ui.module | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index a6a7fa1b57..2d7c2c66bc 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -10,6 +10,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Entity\EntityViewModeInterface; use Drupal\Core\Entity\EntityFormModeInterface; +use Drupal\Core\Url; use Drupal\field_ui\FieldUI; use Drupal\field_ui\Plugin\Derivative\FieldUiLocalTask; @@ -169,24 +170,42 @@ function field_ui_entity_operation(EntityInterface $entity) { if (($bundle_of = $info->getBundleOf()) && \Drupal::entityManager()->getDefinition($bundle_of)->get('field_ui_base_route')) { $account = \Drupal::currentUser(); if ($account->hasPermission('administer ' . $bundle_of . ' fields')) { + // @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. + // Should always use $entity->toUrl() starting from Drupal 9.0.0 onwards. + $url = $entity->hasLinkTemplate('drupal:field-ui-fields') + ? $entity->toUrl('drupal:field-ui-fields') + : Url::fromRoute("entity.{$bundle_of}.field_ui_fields", [$entity->getEntityTypeId() => $entity->id()]); + $operations['manage-fields'] = [ 'title' => t('Manage fields'), 'weight' => 15, - 'url' => $entity->toUrl('drupal:field-ui-fields'), + 'url' => $url, ]; } if ($account->hasPermission('administer ' . $bundle_of . ' form display')) { + // @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. + // Should always use $entity->toUrl() starting from Drupal 9.0.0 onwards. + $url = $entity->hasLinkTemplate('drupal:field-ui-form-display') + ? $entity->toUrl('drupal:field-ui-form-display') + : Url::fromRoute("entity.entity_form_display.{$bundle_of}.default", [$entity->getEntityTypeId() => $entity->id()]); + $operations['manage-form-display'] = [ 'title' => t('Manage form display'), 'weight' => 20, - 'url' => $entity->toUrl('drupal:field-ui-form-display'), + 'url' => $url, ]; } if ($account->hasPermission('administer ' . $bundle_of . ' display')) { + // @deprecated in Drupal 8.7.0 and will be removed before Drupal 9.0.0. + // Should always use $entity->toUrl() starting from Drupal 9.0.0 onwards. + $url = $entity->hasLinkTemplate('drupal:field-ui-display') + ? $entity->toUrl('drupal:field-ui-display') + : Url::fromRoute("entity.entity_view_display.{$bundle_of}.default", [$entity->getEntityTypeId() => $entity->id()]); + $operations['manage-display'] = [ 'title' => t('Manage display'), 'weight' => 25, - 'url' => $entity->toUrl('drupal:field-ui-display'), + 'url' => $url, ]; } } -- 2.17.1