diff --git a/src/Controller/HmMenuController.php b/src/Controller/HmMenuController.php index d101c2eda3ccdffbc96430cdea0f4416a5ab246b..d76abfcf2b3f0e42c1311fb7175413407bd7116c 100644 --- a/src/Controller/HmMenuController.php +++ b/src/Controller/HmMenuController.php @@ -114,9 +114,6 @@ class HmMenuController extends ControllerBase { $parent = ''; } - if (empty($destination)) { - $destination = ''; - } // We indicate that a menu administrator is running the menu access check. $request->attributes->set('_menu_admin', TRUE); diff --git a/src/Controller/HmTaxonomyController.php b/src/Controller/HmTaxonomyController.php index 536b1f4c9fa2792d9958d49922763cb131e000f2..eb70be959824734dcfbfeda23f600c8f840fbedc 100644 --- a/src/Controller/HmTaxonomyController.php +++ b/src/Controller/HmTaxonomyController.php @@ -79,6 +79,7 @@ class HmTaxonomyController extends ControllerBase { } $parent = $request->get('parent') ?: 0; $depth = $request->get('depth'); + $destination = $request->get('destination'); if(!empty($depth)) { $depth = intval($depth); @@ -95,12 +96,18 @@ class HmTaxonomyController extends ControllerBase { if ($term instanceof Term) { // User can only access the terms that they can update. if ($access_control_handler->access($term, 'update')) { + if (empty($destination)) { + $url = $term->toUrl('edit-form')->toString(); + } + else { + $url = $term->toUrl('edit-form', ['query' => ['destination' => $destination]])->toString(); + } $term_array[] = $this->hmPluginTypeManager->buildHierarchyItem( $term->id(), $term->label(), $term->parents[0], - $term->toUrl('edit-form')->toString()); + $url); } } } diff --git a/src/Form/HmMenuForm.php b/src/Form/HmMenuForm.php index 0476df8abe386d0fd624bffd5540aeb03245b6a8..1295c7e463d0ef6b1593f7241bc9abe089982b06 100644 --- a/src/Form/HmMenuForm.php +++ b/src/Form/HmMenuForm.php @@ -2,6 +2,7 @@ namespace Drupal\hierarchy_manager\Form; +use Drupal\Core\Url; use Drupal\Core\Form\FormStateInterface; use Drupal\menu_ui\MenuForm; @@ -80,24 +81,17 @@ class HmMenuForm extends MenuForm { $mid = $this->entity->id(); // CSRF token. $token = \Drupal::csrfToken()->get($mid); - // Get current language. - $language = \Drupal::languageManager()->getCurrentLanguage(); // Destination for edit link. $destination = $this->getDestinationArray(); if (isset($destination['destination'])) { $destination = $destination['destination']; } else { - $destination = ''; - } - if ($language->isDefault()) { - $source_url = $base_path . 'admin/hierarchy_manager/menu/json/' . $mid . '?token=' . $token . '&destination=' . $destination; - $update_url = $base_path . 'admin/hierarchy_manager/menu/update/' . $mid . '?token=' . $token; - } - else { - $source_url = $base_path . $language->getId() . '/admin/hierarchy_manager/menu/json/' . $mid . '?token=' . $token . '&destination=' . $destination; - $update_url = $base_path . $language->getId() . '/admin/hierarchy_manager/menu/update/' . $mid . '?token=' . $token; + $destination = '/'; } + // Urls + $source_url = Url::fromRoute('hierarchy_manager.menu.tree.json', ['mid' => $mid], ['query' => ['token' => $token, 'destination' => $destination]])->toString(); + $update_url = Url::fromRoute('hierarchy_manager.menu.tree.update', ['mid' => $mid], ['query' => ['token' => $token]])->toString(); return $display_plugin_instance->getForm($source_url, $update_url, $form, $form_state); } } diff --git a/src/Form/HmOverviewTerms.php b/src/Form/HmOverviewTerms.php index f4f632c963128e9da44b1faa3dcbd6386f225ee4..c6772a095a571a5602740677317e35eb24230b18 100644 --- a/src/Form/HmOverviewTerms.php +++ b/src/Form/HmOverviewTerms.php @@ -2,6 +2,7 @@ namespace Drupal\hierarchy_manager\Form; +use Drupal\Core\Url; use Drupal\Core\Form\FormStateInterface; use Drupal\taxonomy\VocabularyInterface; use Drupal\taxonomy\Form\OverviewTerms; @@ -51,16 +52,17 @@ class HmOverviewTerms extends OverviewTerms { $vid = $taxonomy_vocabulary->id(); // CSRF token. $token = \Drupal::csrfToken()->get($vid); - // Get current language. - $language = \Drupal::languageManager()->getCurrentLanguage(); - if ($language->isDefault()) { - $source_url = $base_path . 'admin/hierarchy_manager/taxonomy/json/' . $vid . '?token=' . $token; - $update_url = $base_path . 'admin/hierarchy_manager/taxonomy/update/' . $vid . '?token=' . $token; + // Destination for edit link. + $destination = $this->getDestinationArray(); + if (isset($destination['destination'])) { + $destination = $destination['destination']; } else { - $source_url = $base_path . $language->getId() . '/admin/hierarchy_manager/taxonomy/json/' . $vid . '?token=' . $token; - $update_url = $base_path . $language->getId() . '/admin/hierarchy_manager/taxonomy/update/' . $vid . '?token=' . $token; + $destination = '/'; } + // Urls. + $source_url = Url::fromRoute('hierarchy_manager.taxonomy.tree.json', ['vid' => $vid], ['query' => ['token' => $token, 'destination' => $destination]])->toString(); + $update_url = Url::fromRoute('hierarchy_manager.taxonomy.tree.update', ['vid' => $vid], ['query' => ['token' => $token]])->toString(); return $instance->getForm($source_url, $update_url, $form, $form_state); } }