diff --git a/core/modules/field_ui/src/FieldUI.php b/core/modules/field_ui/src/FieldUI.php index 9daf6dd..5983817 100644 --- a/core/modules/field_ui/src/FieldUI.php +++ b/core/modules/field_ui/src/FieldUI.php @@ -30,9 +30,7 @@ class FieldUI { public static function getOverviewRouteInfo($entity_type_id, $bundle) { $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); if ($entity_type->get('field_ui_base_route')) { - return new Url("entity.{$entity_type_id}.field_ui_fields", array( - $entity_type->getBundleEntityType() => $bundle, - )); + return new Url("entity.{$entity_type_id}.field_ui_fields", static::getRouteBundleParameter($entity_type, $bundle)); } } @@ -66,4 +64,19 @@ public static function getNextDestination(array $destinations) { return $next_destination; } + /** + * Gets the route parameter that should be used for Field UI routes. + * + * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type + * The actual entity type, not the bundle (e.g. the content entity type). + * @param string $bundle + * The bundle name. + * + * @return array + * An array that can be used a route parameter. + */ + public static function getRouteBundleParameter(EntityTypeInterface $entity_type, $bundle) { + return array($entity_type->getBundleEntityType() => $bundle); + } + } diff --git a/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php index e8f9b95..cb2086d 100644 --- a/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php +++ b/core/modules/field_ui/src/Form/EntityFormDisplayEditForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Field\PluginSettingsInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -107,9 +108,8 @@ protected function getTableHeader() { protected function getOverviewUrl($mode) { $entity_type = $this->entityManager->getDefinition($this->entity->getTargetEntityTypeId()); return Url::fromRoute('entity.entity_form_display.' . $this->entity->getTargetEntityTypeId() . '.form_mode', [ - $entity_type->getBundleEntityType() => $this->entity->getTargetBundle(), 'form_mode_name' => $mode, - ]); + ] + FieldUI::getRouteBundleParameter($entity_type, $this->entity->getTargetBundle())); } /** diff --git a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php index e7f403d..84331f2 100644 --- a/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php +++ b/core/modules/field_ui/src/Form/EntityViewDisplayEditForm.php @@ -11,6 +11,7 @@ use Drupal\Core\Field\PluginSettingsInterface; use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Url; +use Drupal\field_ui\FieldUI; use Symfony\Component\DependencyInjection\ContainerInterface; /** @@ -141,9 +142,8 @@ protected function getTableHeader() { protected function getOverviewUrl($mode) { $entity_type = $this->entityManager->getDefinition($this->entity->getTargetEntityTypeId()); return Url::fromRoute('entity.entity_view_display.' . $this->entity->getTargetEntityTypeId() . '.view_mode', [ - $entity_type->getBundleEntityType() => $this->entity->getTargetBundle(), 'view_mode_name' => $mode, - ]); + ] + FieldUI::getRouteBundleParameter($entity_type, $this->entity->getTargetBundle())); } /** diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index 89c6b2b..24b7cab 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -311,7 +311,6 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $values = $form_state->getValues(); $destinations = array(); $entity_type = $this->entityManager->getDefinition($this->entityTypeId); - $bundle_entity_type_id = $entity_type->getBundleEntityType(); // Create new field. if ($values['new_storage_type']) { @@ -339,9 +338,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { // Always show the field settings step, as the cardinality needs to be // configured for new fields. $route_parameters = array( - $bundle_entity_type_id => $this->bundle, 'field_config' => $field->id(), - ); + ) + FieldUI::getRouteBundleParameter($entity_type, $this->bundle); $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_storage_edit_form", 'route_parameters' => $route_parameters); $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters); $destinations[] = array('route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters); @@ -371,9 +369,8 @@ public function submitForm(array &$form, FormStateInterface $form_state) { $this->configureEntityDisplays($field_name); $route_parameters = array( - $bundle_entity_type_id => $this->bundle, 'field_config' => $field->id(), - ); + ) + FieldUI::getRouteBundleParameter($entity_type, $this->bundle); $destinations[] = array('route_name' => "entity.field_config.{$this->entityTypeId}_field_edit_form", 'route_parameters' => $route_parameters); $destinations[] = array('route_name' => "entity.{$this->entityTypeId}.field_ui_fields", 'route_parameters' => $route_parameters);