From 744309f9f2d885559b45b06885c77352b506b2a9 Mon Sep 17 00:00:00 2001 From: webchick Date: Wed, 13 Nov 2013 21:31:49 -0800 Subject: [PATCH] Issue #2125253 by tim.plunkett: Convert ()['redirect'] to ()['redirect_route()']. --- core/lib/Drupal/Core/Form/FormBuilder.php | 3 +- .../Drupal/aggregator/FeedFormController.php | 12 +++- .../aggregator/Form/CategoryAdminForm.php | 12 +++- .../aggregator/Form/CategoryDeleteForm.php | 4 +- .../Drupal/aggregator/Form/FeedDeleteForm.php | 4 +- .../aggregator/Form/FeedItemsRemoveForm.php | 2 +- .../Drupal/aggregator/Form/OpmlFeedAdd.php | 2 +- .../ban/lib/Drupal/ban/Form/BanAdmin.php | 2 +- .../ban/lib/Drupal/ban/Form/BanDelete.php | 2 +- .../CustomBlockFormController.php | 27 ++++++--- .../CustomBlockTypeFormController.php | 10 +++- .../Form/CustomBlockDeleteForm.php | 2 +- .../Form/CustomBlockTypeDeleteForm.php | 2 +- .../lib/Drupal/block/BlockFormController.php | 19 +++++-- .../lib/Drupal/block/Form/BlockDeleteForm.php | 2 +- core/modules/book/book.pages.inc | 19 ++----- .../lib/Drupal/book/Form/BookOutlineForm.php | 21 ++++++- core/modules/comment/comment.admin.inc | 2 +- .../comment/Form/ConfirmDeleteMultiple.php | 4 +- .../Drupal/config/Form/ConfigExportForm.php | 2 +- .../Drupal/config/Form/ConfigImportForm.php | 2 +- .../config_test/ConfigTestFormController.php | 10 +++- .../config_test/Form/ConfigTestDeleteForm.php | 2 +- .../Drupal/contact/CategoryFormController.php | 7 ++- .../contact/Form/CategoryDeleteForm.php | 2 +- .../Drupal/contact/MessageFormController.php | 2 +- .../Form/EntityDisplayModeDeleteForm.php | 3 +- .../entity/Form/EntityDisplayModeEditForm.php | 9 ++- .../entity/Form/EntityDisplayModeFormBase.php | 3 +- core/modules/field_ui/field_ui.module | 8 ++- .../Drupal/field_ui/Form/FieldDeleteForm.php | 8 ++- .../Drupal/field_ui/Form/FieldEditForm.php | 14 +++-- .../field_ui/Form/FieldInstanceEditForm.php | 37 ++++++------ .../filter/FilterFormatFormControllerBase.php | 2 +- .../Drupal/filter/Form/FilterDisableForm.php | 2 +- .../lib/Drupal/forum/Form/DeleteForm.php | 2 +- .../Drupal/forum/Form/ForumFormController.php | 14 +++-- .../image/Form/ImageEffectDeleteForm.php | 7 ++- .../Drupal/image/Form/ImageEffectFormBase.php | 7 ++- .../image/Form/ImageStyleDeleteForm.php | 2 +- .../Drupal/image/Form/ImageStyleEditForm.php | 12 +++- .../Drupal/image/Form/ImageStyleFlushForm.php | 2 +- .../Drupal/image/Form/ImageStyleFormBase.php | 7 ++- core/modules/language/language.admin.inc | 2 +- .../Drupal/language/Form/LanguageAddForm.php | 2 +- .../language/Form/LanguageDeleteForm.php | 2 +- .../Drupal/language/Form/LanguageEditForm.php | 2 +- .../Form/NegotiationBrowserDeleteForm.php | 2 +- .../language/Form/NegotiationBrowserForm.php | 2 +- .../language/Form/NegotiationSessionForm.php | 2 +- .../language/Form/NegotiationUrlForm.php | 2 +- .../Drupal/locale/Form/TranslateEditForm.php | 7 ++- .../locale/Form/TranslateFilterForm.php | 4 +- core/modules/locale/locale.bulk.inc | 2 +- .../lib/Drupal/menu/Form/MenuDeleteForm.php | 2 +- .../Drupal/menu/Form/MenuLinkDeleteForm.php | 7 ++- .../Drupal/menu/Form/MenuLinkResetForm.php | 7 ++- .../lib/Drupal/menu/MenuFormController.php | 14 ++++- .../menu_link/MenuLinkFormController.php | 14 ++++- .../lib/Drupal/node/Form/DeleteMultiple.php | 2 +- .../lib/Drupal/node/Form/NodeDeleteForm.php | 2 +- .../node/Form/NodeRevisionDeleteForm.php | 9 ++- .../node/Form/NodeRevisionRevertForm.php | 7 ++- .../node/Form/NodeTypeDeleteConfirm.php | 2 +- .../node/Form/RebuildPermissionsForm.php | 2 +- .../lib/Drupal/node/NodeFormController.php | 23 +++++++- .../Drupal/node/NodeTypeFormController.php | 9 ++- .../picture/Form/PictureMappingDeleteForm.php | 2 +- .../picture/PictureMappingFormController.php | 10 +++- .../lib/Drupal/search/Form/ReindexConfirm.php | 3 +- .../Drupal/search/Form/SearchBlockForm.php | 7 ++- .../Drupal/search/Form/SearchSettingsForm.php | 2 +- core/modules/search/search.module | 57 ------------------- .../lib/Drupal/shortcut/Form/LinkDelete.php | 7 ++- .../shortcut/Form/ShortcutSetDeleteForm.php | 2 +- .../shortcut/ShortcutSetFormController.php | 15 ++++- core/modules/shortcut/shortcut.admin.inc | 21 ++++++- .../simpletest/Form/SimpletestResultsForm.php | 4 +- .../simpletest/Form/SimpletestTestForm.php | 7 ++- .../system/Form/DateFormatDeleteForm.php | 2 +- .../Drupal/system/Form/DateFormatFormBase.php | 2 +- .../system/Form/ModulesListConfirmForm.php | 2 +- .../Drupal/system/Form/ModulesListForm.php | 2 +- .../Form/ModulesUninstallConfirmForm.php | 2 +- .../system/Form/ModulesUninstallForm.php | 4 +- .../tests/modules/ajax_test/ajax_test.module | 2 +- .../modules/batch_test/batch_test.module | 12 ++-- .../entity_test/EntityTestFormController.php | 10 +++- .../tests/modules/form_test/form_test.module | 2 +- .../Drupal/form_test/ConfirmFormTestForm.php | 2 +- .../Drupal/taxonomy/Form/OverviewTerms.php | 5 +- .../Drupal/taxonomy/Form/TermDeleteForm.php | 2 +- .../taxonomy/Form/VocabularyDeleteForm.php | 2 +- .../taxonomy/Form/VocabularyResetForm.php | 5 +- .../Drupal/taxonomy/TermFormController.php | 6 +- .../taxonomy/VocabularyFormController.php | 12 +++- .../lib/Drupal/user/Form/UserCancelForm.php | 7 ++- .../lib/Drupal/user/Form/UserLoginForm.php | 5 +- .../user/Form/UserMultipleCancelConfirm.php | 2 +- .../lib/Drupal/user/Form/UserPasswordForm.php | 2 +- .../lib/Drupal/user/Form/UserRoleDelete.php | 2 +- .../lib/Drupal/user/ProfileFormController.php | 6 +- .../Drupal/user/RegisterFormController.php | 6 +- .../lib/Drupal/user/RoleFormController.php | 7 ++- .../lib/Drupal/views_ui/Form/Ajax/Analyze.php | 5 +- .../Drupal/views_ui/Form/BreakLockForm.php | 5 +- .../Drupal/views_ui/ViewAddFormController.php | 9 ++- .../views_ui/ViewDeleteFormController.php | 2 +- .../views_ui/ViewEditFormController.php | 42 +++++++++++--- .../views_ui/lib/Drupal/views_ui/ViewUI.php | 5 +- 110 files changed, 494 insertions(+), 268 deletions(-) diff --git a/core/lib/Drupal/Core/Form/FormBuilder.php b/core/lib/Drupal/Core/Form/FormBuilder.php index 38bfab7f715..cbaf9080830 100644 --- a/core/lib/Drupal/Core/Form/FormBuilder.php +++ b/core/lib/Drupal/Core/Form/FormBuilder.php @@ -419,6 +419,7 @@ class FormBuilder implements FormBuilderInterface { 'rebuild', 'rebuild_info', 'redirect', + 'redirect_route', 'no_redirect', 'temporary', // Internal properties defined by form processing. @@ -640,7 +641,7 @@ class FormBuilder implements FormBuilderInterface { $batch['form_state'] = $form_state; } else { - $batch['form_state'] = array_intersect_key($form_state, array_flip(array('programmed', 'rebuild', 'storage', 'no_redirect', 'redirect'))); + $batch['form_state'] = array_intersect_key($form_state, array_flip(array('programmed', 'rebuild', 'storage', 'no_redirect', 'redirect', 'redirect_route'))); } $batch['progressive'] = !$form_state['programmed']; diff --git a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php index d4761f5eab3..899bb400a0c 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/FeedFormController.php @@ -146,10 +146,13 @@ class FeedFormController extends ContentEntityFormController { if ($insert) { drupal_set_message($this->t('The feed %feed has been updated.', array('%feed' => $feed->label()))); if (arg(0) == 'admin') { - $form_state['redirect'] = 'admin/config/services/aggregator'; + $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; } else { - $form_state['redirect'] = 'aggregator/sources/' . $feed->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'aggregator.feed_view', + 'route_parameters' => array('aggregator_feed' => $feed->id()), + ); } } else { @@ -162,7 +165,10 @@ class FeedFormController extends ContentEntityFormController { * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/config/services/aggregator/delete/feed/' . $this->entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'aggregator.feed_delete', + 'route_parameters' => array('aggregator_feed' => $this->entity->id()), + ); } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryAdminForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryAdminForm.php index 68372c9d237..a24a420d271 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryAdminForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryAdminForm.php @@ -144,7 +144,10 @@ class CategoryAdminForm extends FormBase { // Redirect to a confirm delete form. if ($form_state['values']['op'] == $this->t('Delete')) { $cid = $form_state['values']['cid']; - $form_state['redirect'] = 'admin/config/services/aggregator/delete/category/' . $cid; + $form_state['redirect_route'] = array( + 'route_name' => 'aggregator.category_delete', + 'route_parameters' => array('cid' => $cid), + ); return; } @@ -154,10 +157,13 @@ class CategoryAdminForm extends FormBase { $this->categoryStorageController->update((object) $form_state['values']); drupal_set_message($this->t('The category %category has been updated.', array('%category' => $title))); if (preg_match('/^\/admin/', $this->getRequest()->getPathInfo())) { - $form_state['redirect'] = 'admin/config/services/aggregator/'; + $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; } else { - $form_state['redirect'] = 'aggregator/categories/' . $cid; + $form_state['redirect_route'] = array( + 'route_name' => 'aggregator.category_view', + 'route_parameters' => array('cid' => $cid), + ); } $this->updateMenuLink('update', $link_path . $cid, $title); return; diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php index 43c0ffaf042..0335e04f63e 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/CategoryDeleteForm.php @@ -149,10 +149,10 @@ class CategoryDeleteForm extends ConfirmFormBase implements ContainerInjectionIn watchdog('aggregator', 'Category %category deleted.', array('%category' => $title)); drupal_set_message($this->t('The category %category has been deleted.', array('%category' => $title))); if (preg_match('/^\/admin/', $this->getRequest()->getPathInfo())) { - $form_state['redirect'] = 'admin/config/services/aggregator/'; + $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; } else { - $form_state['redirect'] = 'aggregator'; + $form_state['redirect_route']['route_name'] = 'aggregator.page_last'; } $this->updateMenuLink('delete', 'aggregator/categories/' . $cid, $title); } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php index adad1eeed4b..7cc382731ec 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedDeleteForm.php @@ -45,10 +45,10 @@ class FeedDeleteForm extends ContentEntityConfirmFormBase { watchdog('aggregator', 'Feed %feed deleted.', array('%feed' => $this->entity->label())); drupal_set_message($this->t('The feed %feed has been deleted.', array('%feed' => $this->entity->label()))); if (arg(0) == 'admin') { - $form_state['redirect'] = 'admin/config/services/aggregator'; + $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; } else { - $form_state['redirect'] = 'aggregator/sources'; + $form_state['redirect_route']['route_name'] = 'aggregator.sources'; } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php index 54b7d5a97a2..05168c594fd 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/FeedItemsRemoveForm.php @@ -43,7 +43,7 @@ class FeedItemsRemoveForm extends ContentEntityConfirmFormBase { public function submit(array $form, array &$form_state) { $this->entity->removeItems(); - $form_state['redirect'] = 'admin/config/services/aggregator'; + $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; } } diff --git a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php index abf1cad4aac..748574fabcc 100644 --- a/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php +++ b/core/modules/aggregator/lib/Drupal/aggregator/Form/OpmlFeedAdd.php @@ -213,7 +213,7 @@ class OpmlFeedAdd extends FormBase { $new_feed->save(); } - $form_state['redirect'] = 'admin/config/services/aggregator'; + $form_state['redirect_route']['route_name'] = 'aggregator.admin_overview'; } /** diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php index f15f7341605..8461d676ab3 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanAdmin.php @@ -121,7 +121,7 @@ class BanAdmin extends FormBase { $ip = trim($form_state['values']['ip']); $this->ipManager->banIp($ip); drupal_set_message($this->t('The IP address %ip has been banned.', array('%ip' => $ip))); - $form_state['redirect'] = 'admin/config/people/ban'; + $form_state['redirect_route']['route_name'] = 'ban.admin_page'; } } diff --git a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php index 43b5359a402..e8fce2ed9cf 100644 --- a/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php +++ b/core/modules/ban/lib/Drupal/ban/Form/BanDelete.php @@ -93,7 +93,7 @@ class BanDelete extends ConfirmFormBase { $this->ipManager->unbanIp($this->banIp); watchdog('user', 'Deleted %ip', array('%ip' => $this->banIp)); drupal_set_message($this->t('The IP address %ip was deleted.', array('%ip' => $this->banIp))); - $form_state['redirect'] = 'admin/config/people/ban'; + $form_state['redirect_route']['route_name'] = 'ban.admin_page'; } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php index fb818fcabb8..ffa7d478846 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockFormController.php @@ -183,15 +183,19 @@ class CustomBlockFormController extends ContentEntityFormController { $form_state['values']['id'] = $block->id->value; $form_state['id'] = $block->id->value; if ($insert) { - if ($theme = $block->getTheme()) { - $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . $theme; - } - else { - $form_state['redirect'] = 'admin/structure/block/add/custom_block:' . $block->uuid->value . '/' . \Drupal::config('system.theme')->get('default'); + if (!$theme = $block->getTheme()) { + $theme = $this->config('system.theme')->get('default'); } + $form_state['redirect_route'] = array( + 'route_name' => 'block.admin_add', + 'route_parameters' => array( + 'plugin_id' => 'custom_block:' . $block->uuid(), + 'theme' => $theme, + ), + ); } else { - $form_state['redirect'] = 'admin/structure/block/custom-blocks'; + $form_state['redirect_route']['route_name'] = 'custom_block.list'; } } else { @@ -215,8 +219,15 @@ class CustomBlockFormController extends ContentEntityFormController { $destination = drupal_get_destination(); $query->remove('destination'); } - $block = $this->buildEntity($form, $form_state); - $form_state['redirect'] = array('block/' . $block->id() . '/delete', array('query' => $destination)); + $form_state['redirect_route'] = array( + 'route_name' => 'custom_block.delete', + 'route_parameters' => array( + 'custom_block' => $this->entity->id(), + ), + 'options' => array( + 'query' => $destination, + ), + ); } /** diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php index a3e143fb247..15cd8f8fc63 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/CustomBlockTypeFormController.php @@ -101,15 +101,19 @@ class CustomBlockTypeFormController extends EntityFormController { watchdog('custom_block', 'Custom block type %label has been added.', array('%label' => $block_type->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit')); } - $form_state['redirect'] = 'admin/structure/block/custom-blocks/types'; + $form_state['redirect_route']['route_name'] = 'custom_block.type_list'; } /** * Overrides \Drupal\Core\Entity\EntityFormController::delete(). */ public function delete(array $form, array &$form_state) { - $block_type = $this->entity; - $form_state['redirect'] = 'admin/structure/block/custom-blocks/manage/' . $block_type->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'custom_block.type_delete', + 'route_parameters' => array( + 'custom_block_type' => $this->entity->id(), + ), + ); } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php index 012a9b071d7..96ee5f06ca7 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockDeleteForm.php @@ -60,7 +60,7 @@ class CustomBlockDeleteForm extends ContentEntityConfirmFormBase { $this->entity->delete(); drupal_set_message($this->t('Custom block %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('custom_block', 'Custom block %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/block/custom-blocks'; + $form_state['redirect_route']['route_name'] = 'custom_block.list'; } } diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php index 01433ae659c..e065e651009 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Form/CustomBlockTypeDeleteForm.php @@ -85,7 +85,7 @@ class CustomBlockTypeDeleteForm extends EntityConfirmFormBase { */ public function submit(array $form, array &$form_state) { $this->entity->delete(); - $form_state['redirect'] = 'admin/structure/block/custom-blocks/types'; + $form_state['redirect_route']['route_name'] = 'custom_block.type_list'; drupal_set_message(t('Custom block type %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('custom_block', 'Custom block type %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); } diff --git a/core/modules/block/lib/Drupal/block/BlockFormController.php b/core/modules/block/lib/Drupal/block/BlockFormController.php index 849123850e7..6d88f11d518 100644 --- a/core/modules/block/lib/Drupal/block/BlockFormController.php +++ b/core/modules/block/lib/Drupal/block/BlockFormController.php @@ -326,9 +326,15 @@ class BlockFormController extends EntityFormController { // Invalidate the content cache and redirect to the block listing, // because we need to remove cached block contents for each cache backend. Cache::invalidateTags(array('content' => TRUE)); - $form_state['redirect'] = array('admin/structure/block/list/' . $form_state['values']['theme'], array( - 'query' => array('block-placement' => drupal_html_class($this->entity->id())), - )); + $form_state['redirect_route'] = array( + 'route_name' => 'block.admin_display_theme', + 'route_parameters' => array( + 'theme' => $form_state['values']['theme'], + ), + 'options' => array( + 'query' => array('block-placement' => drupal_html_class($this->entity->id())) + ), + ); } /** @@ -336,7 +342,12 @@ class BlockFormController extends EntityFormController { */ public function delete(array $form, array &$form_state) { parent::delete($form, $form_state); - $form_state['redirect'] = 'admin/structure/block/manage/' . $this->entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'block.admin_block_delete', + 'route_parameters' => array( + 'block' => $this->entity->id(), + ), + ); } /** diff --git a/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php b/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php index ce381cc3da2..20c1e7e526e 100644 --- a/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php +++ b/core/modules/block/lib/Drupal/block/Form/BlockDeleteForm.php @@ -43,7 +43,7 @@ class BlockDeleteForm extends EntityConfirmFormBase { public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message($this->t('The block %name has been removed.', array('%name' => $this->entity->label()))); - $form_state['redirect'] = 'admin/structure/block'; + $form_state['redirect_route']['route_name'] = 'block.admin_display'; } } diff --git a/core/modules/book/book.pages.inc b/core/modules/book/book.pages.inc index 5e7b4de7838..d01636cb06d 100644 --- a/core/modules/book/book.pages.inc +++ b/core/modules/book/book.pages.inc @@ -9,18 +9,6 @@ use Drupal\Core\Entity\EntityInterface; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; - -/** - * Form submission handler for book_outline_form(). - * - * Redirects to removal confirmation form. - * - * @see book_outline_form_submit() - */ -function book_remove_button_submit($form, &$form_state) { - $form_state['redirect'] = 'node/' . $form['#node']->id() . '/outline/remove'; -} - /** * Form constructor to confirm removal of a node from a book. * @@ -59,5 +47,10 @@ function book_remove_form_submit($form, &$form_state) { ->execute(); drupal_set_message(t('The post has been removed from the book.')); } - $form_state['redirect'] = 'node/' . $node->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'node.view', + 'route_parameters' => array( + 'node' => $node->id(), + ), + ); } diff --git a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php index 61ff1fc763f..5364d938e71 100644 --- a/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php +++ b/core/modules/book/lib/Drupal/book/Form/BookOutlineForm.php @@ -101,7 +101,12 @@ class BookOutlineForm extends ContentEntityFormController { * @see book_remove_button_submit() */ public function submit(array $form, array &$form_state) { - $form_state['redirect'] = 'node/' . $this->entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'node.view', + 'route_parameters' => array( + 'node' => $this->entity->id(), + ), + ); $book_link = $form_state['values']['book']; if (!$book_link['bid']) { drupal_set_message($this->t('No changes were made')); @@ -114,7 +119,12 @@ class BookOutlineForm extends ContentEntityFormController { if ($this->entity->book['parent_mismatch']) { // This will usually only happen when JS is disabled. drupal_set_message($this->t('The post has been added to the selected book. You may now position it relative to other pages.')); - $form_state['redirect'] = 'node/' . $this->entity->id() . '/outline'; + $form_state['redirect_route'] = array( + 'route_name' => 'book.outline', + 'route_parameters' => array( + 'node' => $this->entity->id(), + ), + ); } else { drupal_set_message($this->t('The book outline has been updated.')); @@ -129,7 +139,12 @@ class BookOutlineForm extends ContentEntityFormController { * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'node/' . $this->entity->id() . '/outline/remove'; + $form_state['redirect_route'] = array( + 'route_name' => 'book.remove', + 'route_parameters' => array( + 'node' => $this->entity->id(), + ), + ); } } diff --git a/core/modules/comment/comment.admin.inc b/core/modules/comment/comment.admin.inc index f17fa594264..c1726be12c6 100644 --- a/core/modules/comment/comment.admin.inc +++ b/core/modules/comment/comment.admin.inc @@ -225,6 +225,6 @@ function comment_admin_overview_submit($form, &$form_state) { } } drupal_set_message(t('The update has been performed.')); - $form_state['redirect'] = 'admin/content/comment'; + $form_state['redirect_route']['route_name'] = 'comment.admin'; cache_invalidate_tags(array('content' => TRUE)); } diff --git a/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php b/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php index 97884ca9327..19672775672 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php +++ b/core/modules/comment/lib/Drupal/comment/Form/ConfirmDeleteMultiple.php @@ -107,7 +107,7 @@ class ConfirmDeleteMultiple extends ConfirmFormBase implements ContainerInjectio if (!$comment_counter) { drupal_set_message($this->t('There do not appear to be any comments to delete, or your selected comment was deleted by another administrator.')); - $form_state['redirect'] = 'admin/content/comment'; + $form_state['redirect_route']['route_name'] = 'comment.admin'; } $form = parent::buildForm($form, $form_state); @@ -128,7 +128,7 @@ class ConfirmDeleteMultiple extends ConfirmFormBase implements ContainerInjectio watchdog('content', 'Deleted @count comments.', array('@count' => $count)); drupal_set_message(format_plural($count, 'Deleted 1 comment.', 'Deleted @count comments.')); } - $form_state['redirect'] = 'admin/content/comment'; + $form_state['redirect_route']['route_name'] = 'comment.admin'; } } diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php index 7f41e501ff9..c3518180f96 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigExportForm.php @@ -39,7 +39,7 @@ class ConfigExportForm extends FormBase { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $form_state['redirect'] = 'admin/config/development/configuration/full/export-download'; + $form_state['redirect_route']['route_name'] = 'config.export_download'; } } diff --git a/core/modules/config/lib/Drupal/config/Form/ConfigImportForm.php b/core/modules/config/lib/Drupal/config/Form/ConfigImportForm.php index 2d5c4a882a1..c6a9304e148 100644 --- a/core/modules/config/lib/Drupal/config/Form/ConfigImportForm.php +++ b/core/modules/config/lib/Drupal/config/Form/ConfigImportForm.php @@ -96,7 +96,7 @@ class ConfigImportForm extends FormBase { } $archiver->extractList($files, config_get_config_directory(CONFIG_STAGING_DIRECTORY)); drupal_set_message($this->t('Your configuration files were successfully uploaded, ready for import.')); - $form_state['redirect'] = 'admin/config/development/configuration'; + $form_state['redirect_route']['route_name'] = 'config.sync'; } catch (\Exception $e) { form_set_error('import_tarball', $this->t('Could not extract the contents of the tar file. The error message is @message', array('@message' => $e->getMessage()))); diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php index 119774bfa32..514311b92f8 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/ConfigTestFormController.php @@ -79,15 +79,19 @@ class ConfigTestFormController extends EntityFormController { drupal_set_message(format_string('%label configuration has been created.', array('%label' => $entity->label()))); } - $form_state['redirect'] = 'admin/structure/config_test'; + $form_state['redirect_route']['route_name'] = 'config_test.list_page'; } /** * Overrides Drupal\Core\Entity\EntityFormController::delete(). */ public function delete(array $form, array &$form_state) { - $entity = $this->entity; - $form_state['redirect'] = 'admin/structure/config_test/manage/' . $entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'config_test.entity_delete', + 'route_parameters' => array( + 'config_test' => $this->entity->id(), + ), + ); } } diff --git a/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php b/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php index c41396d482d..4d0a184e0c3 100644 --- a/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php +++ b/core/modules/config/tests/config_test/lib/Drupal/config_test/Form/ConfigTestDeleteForm.php @@ -43,7 +43,7 @@ class ConfigTestDeleteForm extends EntityConfirmFormBase { public function submit(array $form, array &$form_state) { $this->entity->delete(); drupal_set_message(String::format('%label configuration has been deleted.', array('%label' => $this->entity->label()))); - $form_state['redirect'] = 'admin/structure/config_test'; + $form_state['redirect_route']['route_name'] = 'config_test.list_page'; } } diff --git a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php index bd12a6637fa..a383881d8b5 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryFormController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryFormController.php @@ -121,14 +121,17 @@ class CategoryFormController extends EntityFormController { ->save(); } - $form_state['redirect'] = 'admin/structure/contact'; + $form_state['redirect_route']['route_name'] = 'contact.category_list'; } /** * Overrides Drupal\Core\Entity\EntityFormController::delete(). */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/contact/manage/' . $this->entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'contact.category_delete', + 'route_parameters' => array('contact_category' => $this->entity->id()), + ); } } diff --git a/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php b/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php index 9b74947e2be..dac498ef5b2 100644 --- a/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php +++ b/core/modules/contact/lib/Drupal/contact/Form/CategoryDeleteForm.php @@ -44,7 +44,7 @@ class CategoryDeleteForm extends EntityConfirmFormBase { $this->entity->delete(); drupal_set_message(t('Category %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('contact', 'Category %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/contact'; + $form_state['redirect_route']['route_name'] = 'contact.category_list'; } } diff --git a/core/modules/contact/lib/Drupal/contact/MessageFormController.php b/core/modules/contact/lib/Drupal/contact/MessageFormController.php index b056dc649b9..ca4a607089d 100644 --- a/core/modules/contact/lib/Drupal/contact/MessageFormController.php +++ b/core/modules/contact/lib/Drupal/contact/MessageFormController.php @@ -212,7 +212,7 @@ class MessageFormController extends ContentEntityFormController { $form_state['redirect'] = array($uri['path'], $uri['options']); } else { - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php index aa26aeef86e..beee9d7e84f 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeDeleteForm.php @@ -56,8 +56,7 @@ class EntityDisplayModeDeleteForm extends EntityConfirmFormBase { drupal_set_message(t('Deleted the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => strtolower($entity_info['label'])))); $this->entity->delete(); entity_info_cache_clear(); - $short_type = str_replace('_mode', '', $this->entity->entityType()); - $form_state['redirect'] = "admin/structure/display-modes/$short_type"; + $form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->entityType() . '_list'; } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php index f413fe43e11..48c2b96f1ff 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeEditForm.php @@ -16,8 +16,13 @@ class EntityDisplayModeEditForm extends EntityDisplayModeFormBase { * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $short_type = str_replace('_mode', '', $this->entity->entityType()); - $form_state['redirect'] = "admin/structure/display-modes/$short_type/manage/" . $this->entity->id() . '/delete'; + $entity_type = $this->entity->entityType(); + $form_state['redirect_route'] = array( + 'route_name' => 'entity.' . $entity_type . '_delete', + 'route_parameters' => array( + $entity_type => $this->entity->id(), + ), + ); } } diff --git a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php index 1d8ada92675..dc969223a12 100644 --- a/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php +++ b/core/modules/entity/lib/Drupal/entity/Form/EntityDisplayModeFormBase.php @@ -122,8 +122,7 @@ abstract class EntityDisplayModeFormBase extends EntityFormController { drupal_set_message(t('Saved the %label @entity-type.', array('%label' => $this->entity->label(), '@entity-type' => strtolower($this->entityInfo['label'])))); $this->entity->save(); entity_info_cache_clear(); - $short_type = str_replace('_mode', '', $this->entity->entityType()); - $form_state['redirect'] = "admin/structure/display-modes/$short_type"; + $form_state['redirect_route']['route_name'] = 'entity.' . $this->entity->entityType() . '_list'; } } diff --git a/core/modules/field_ui/field_ui.module b/core/modules/field_ui/field_ui.module index dc0d38f64c3..f9d90c6c486 100644 --- a/core/modules/field_ui/field_ui.module +++ b/core/modules/field_ui/field_ui.module @@ -334,8 +334,12 @@ function field_ui_entity_operation_alter(array &$operations, EntityInterface $en */ function field_ui_form_node_type_form_submit($form, &$form_state) { if ($form_state['triggering_element']['#parents'][0] === 'save_continue') { - $admin_path = \Drupal::entityManager()->getAdminPath('node', $form_state['values']['type']); - $form_state['redirect'] = "$admin_path/fields"; + $form_state['redirect_route'] = array( + 'route_name' => 'field_ui.overview_node', + 'route_parameters' => array( + 'bundle' => $form_state['values']['type'], + ), + ); } } diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php index 16f200430a6..7e37efb086c 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldDeleteForm.php @@ -79,8 +79,12 @@ class FieldDeleteForm extends EntityConfirmFormBase { drupal_set_message($this->t('There was a problem removing the %field from the %type content type.', array('%field' => $this->entity->label(), '%type' => $bundle_label)), 'error'); } - $admin_path = $this->entityManager->getAdminPath($this->entity->entity_type, $this->entity->bundle); - $form_state['redirect'] = "$admin_path/fields"; + $form_state['redirect_route'] = array( + 'route_name' => 'field_ui.overview_' . $this->entity->entity_type, + 'route_parameters' => array( + 'bundle' => $this->entity->bundle, + ) + ); // Fields are purged on cron. However field module prevents disabling modules // when field types they provided are used in a field until it is fully diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php index 5ce355c9cb7..062dd40884b 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldEditForm.php @@ -202,11 +202,17 @@ class FieldEditForm extends FormBase { try { $field->save(); drupal_set_message($this->t('Updated field %label field settings.', array('%label' => $this->instance->label()))); - $next_destination = FieldUI::getNextDestination($this->getRequest()); - if (empty($next_destination)) { - $next_destination = $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle) . '/fields'; + if ($next_destination = FieldUI::getNextDestination($this->getRequest())) { + $form_state['redirect'] = $next_destination; + } + else { + $form_state['redirect_route'] = array( + 'route_name' => 'field_ui.overview_' . $this->instance->entity_type, + 'route_parameters' => array( + 'bundle' => $this->instance->bundle, + ) + ); } - $form_state['redirect'] = $next_destination; } catch (\Exception $e) { drupal_set_message($this->t('Attempt to update field %label failed: %message.', array('%label' => $this->instance->label(), '%message' => $e->getMessage())), 'error'); diff --git a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php index 642992ff457..7b507452711 100644 --- a/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php +++ b/core/modules/field_ui/lib/Drupal/field_ui/Form/FieldInstanceEditForm.php @@ -189,7 +189,17 @@ class FieldInstanceEditForm extends FormBase { drupal_set_message($this->t('Saved %label configuration.', array('%label' => $this->instance->getFieldLabel()))); - $form_state['redirect'] = $this->getNextDestination(); + if ($next_destination = FieldUI::getNextDestination($this->getRequest())) { + $form_state['redirect'] = $next_destination; + } + else { + $form_state['redirect_route'] = array( + 'route_name' => 'field_ui.overview_' . $this->instance->entity_type, + 'route_parameters' => array( + 'bundle' => $this->instance->bundle, + ) + ); + } } /** @@ -202,21 +212,16 @@ class FieldInstanceEditForm extends FormBase { $destination = drupal_get_destination(); $request->query->remove('destination'); } - $form_state['redirect'] = array('admin/structure/types/manage/' . $this->instance->bundle . '/fields/' . $this->instance->id() . '/delete', array('query' => $destination)); - } - - /** - * Returns the next redirect path in a multipage sequence. - * - * @return string|array - * Either the next path, or an array of redirect paths. - */ - protected function getNextDestination() { - $next_destination = FieldUI::getNextDestination($this->getRequest()); - if (empty($next_destination)) { - $next_destination = $this->entityManager->getAdminPath($this->instance->entity_type, $this->instance->bundle) . '/fields'; - } - return $next_destination; + $form_state['redirect_route'] = array( + 'route_name' => 'field_ui.delete_' . $this->instance->entity_type, + 'route_parameters' => array( + 'bundle' => $this->instance->bundle, + 'field_instance' => $this->instance->id(), + ), + 'options' => array( + 'query' => $destination, + ), + ); } } diff --git a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php index bd429694f8d..fd79f0200de 100644 --- a/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php +++ b/core/modules/filter/lib/Drupal/filter/FilterFormatFormControllerBase.php @@ -263,7 +263,7 @@ abstract class FilterFormatFormControllerBase extends EntityFormController { } } - $form_state['redirect'] = 'admin/config/content/formats'; + $form_state['redirect_route']['route_name'] = 'filter.admin_overview'; return $this->entity; } diff --git a/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php b/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php index 8cf93d2a388..125015efdde 100644 --- a/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php +++ b/core/modules/filter/lib/Drupal/filter/Form/FilterDisableForm.php @@ -51,7 +51,7 @@ class FilterDisableForm extends EntityConfirmFormBase { $this->entity->disable()->save(); drupal_set_message(t('Disabled text format %format.', array('%format' => $this->entity->label()))); - $form_state['redirect'] = 'admin/config/content/formats'; + $form_state['redirect_route']['route_name'] = 'filter.admin_overview'; } } diff --git a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php index 5e4d66015ee..66f0545f352 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php +++ b/core/modules/forum/lib/Drupal/forum/Form/DeleteForm.php @@ -69,7 +69,7 @@ class DeleteForm extends ConfirmFormBase { $this->taxonomyTerm->delete(); drupal_set_message($this->t('The forum %label and all sub-forums have been deleted.', array('%label' => $this->taxonomyTerm->label()))); watchdog('forum', 'forum: deleted %label and all its sub-forums.', array('%label' => $this->taxonomyTerm->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/forum'; + $form_state['redirect_route']['route_name'] = 'forum.overview'; } } diff --git a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php index 7b758ef48f7..0605c0a7b4f 100644 --- a/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php +++ b/core/modules/forum/lib/Drupal/forum/Form/ForumFormController.php @@ -94,7 +94,7 @@ class ForumFormController extends TermFormController { break; } - $form_state['redirect'] = 'admin/structure/forum'; + $form_state['redirect_route']['route_name'] = 'forum.overview'; return $term; } @@ -108,10 +108,14 @@ class ForumFormController extends TermFormController { $destination = drupal_get_destination(); $request->query->remove('destination'); } - $term = $this->getEntity($form_state); - $form_state['redirect'] = array( - 'admin/structure/forum/delete/forum/' . $term->id(), - array('query' => $destination), + $form_state['redirect_route'] = array( + 'route_name' => 'forum.delete', + 'route_parameters' => array( + 'taxonomy_term' => $this->entity->id(), + ), + 'options' => array( + 'query' => $destination, + ), ); } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php index 5f26db34c34..edc71afcb5e 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectDeleteForm.php @@ -78,7 +78,12 @@ class ImageEffectDeleteForm extends ConfirmFormBase { public function submitForm(array &$form, array &$form_state) { $this->imageStyle->deleteImageEffect($this->imageEffect); drupal_set_message($this->t('The image effect %name has been deleted.', array('%name' => $this->imageEffect->label()))); - $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $this->imageStyle->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'image.style_edit', + 'route_parameters' => array( + 'image_style' => $this->imageStyle->id(), + ), + ); } } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php b/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php index c26ab8cb1c5..8ddc426390b 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageEffectFormBase.php @@ -107,7 +107,12 @@ abstract class ImageEffectFormBase extends FormBase { $this->imageStyle->saveImageEffect($form_state['values']); drupal_set_message($this->t('The image effect was successfully applied.')); - $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $this->imageStyle->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'image.style_edit', + 'route_parameters' => array( + 'image_style' => $this->imageStyle->id(), + ), + ); } /** diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php index 6cfe35497b7..470f31dda21 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleDeleteForm.php @@ -66,7 +66,7 @@ class ImageStyleDeleteForm extends EntityConfirmFormBase { $this->entity->set('replacementID', $form_state['values']['replacement']); $this->entity->delete(); drupal_set_message($this->t('Style %name was deleted.', array('%name' => $this->entity->label()))); - $form_state['redirect'] = 'admin/config/media/image-styles'; + $form_state['redirect_route']['route_name'] = 'image.style_list'; } } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php index 50c665e2da2..12062136c09 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleEditForm.php @@ -184,8 +184,16 @@ class ImageStyleEditForm extends ImageStyleFormBase { // Load the configuration form for this option. if (is_subclass_of($effect['class'], '\Drupal\image\ConfigurableImageEffectInterface')) { - $path = 'admin/config/media/image-styles/manage/' . $this->entity->id() . '/add/' . $form_state['values']['new']; - $form_state['redirect'] = array($path, array('query' => array('weight' => $form_state['values']['weight']))); + $form_state['redirect_route'] = array( + 'route_name' => 'image.effect_add_form', + 'route_parameters' => array( + 'image_style' => $this->entity->id(), + 'image_effect' => $form_state['values']['new'], + ), + 'options' => array( + 'query' => array('weight' => $form_state['values']['weight']), + ), + ); } // If there's no form, immediately add the image effect. else { diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php index 41aa0238b32..2c87bb21c72 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleFlushForm.php @@ -50,7 +50,7 @@ class ImageStyleFlushForm extends EntityConfirmFormBase { public function submit(array $form, array &$form_state) { $this->entity->flush(); drupal_set_message($this->t('The image style %name has been flushed.', array('%name' => $this->entity->label()))); - $form_state['redirect'] = 'admin/config/media/image-styles'; + $form_state['redirect_route']['route_name'] = 'image.style_list'; } } diff --git a/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php b/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php index 0b16e802342..3ec0b2d4b13 100644 --- a/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php +++ b/core/modules/image/lib/Drupal/image/Form/ImageStyleFormBase.php @@ -69,7 +69,12 @@ abstract class ImageStyleFormBase extends EntityFormController { * {@inheritdoc} */ public function save(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/config/media/image-styles/manage/' . $this->entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'image.style_edit', + 'route_parameters' => array( + 'image_style' => $this->entity->id(), + ), + ); return $this->entity->save(); } diff --git a/core/modules/language/language.admin.inc b/core/modules/language/language.admin.inc index e7403428e54..f9443c7510a 100644 --- a/core/modules/language/language.admin.inc +++ b/core/modules/language/language.admin.inc @@ -281,7 +281,7 @@ function language_negotiation_configure_form_submit($form, &$form_state) { \Drupal::service('plugin.manager.block')->clearCachedDefinitions(); } - $form_state['redirect'] = 'admin/config/regional/language/detection'; + $form_state['redirect_route']['route_name'] = 'language.negotiation'; drupal_set_message(t('Language negotiation configuration saved.')); } diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php index 111bdfc6ba7..09420b0f81d 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageAddForm.php @@ -103,7 +103,7 @@ class LanguageAddForm extends LanguageFormBase { // Tell the user they have the option to add a language switcher block // to their theme so they can switch between the languages. drupal_set_message($this->t('Use one of the language switcher blocks to allow site visitors to switch between languages. You can enable these blocks on the block administration page.', array('@block-admin' => url('admin/structure/block')))); - $form_state['redirect'] = 'admin/config/regional/language'; + $form_state['redirect_route']['route_name'] = 'language.admin_overview'; } /** diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php index dcb1f96e9a4..241bbe77463 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageDeleteForm.php @@ -115,7 +115,7 @@ class LanguageDeleteForm extends EntityConfirmFormBase { drupal_set_message($this->t('The %language (%langcode) language has been removed.', array('%language' => $this->entity->label(), '%langcode' => $this->entity->id()))); } - $form_state['redirect'] = 'admin/config/regional/language'; + $form_state['redirect_route']['route_name'] = 'language.admin_overview'; } } diff --git a/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php b/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php index 6c61a8b61af..66e1ed17df3 100644 --- a/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php +++ b/core/modules/language/lib/Drupal/language/Form/LanguageEditForm.php @@ -54,7 +54,7 @@ class LanguageEditForm extends LanguageFormBase { $language->name = $form_state['values']['name']; $language->direction = $form_state['values']['direction']; language_save($language); - $form_state['redirect'] = 'admin/config/regional/language'; + $form_state['redirect_route']['route_name'] = 'language.admin_overview'; } } diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserDeleteForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserDeleteForm.php index 51f161bb500..1d4260b43a7 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserDeleteForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserDeleteForm.php @@ -66,7 +66,7 @@ class NegotiationBrowserDeleteForm extends ConfirmFormBase { language_set_browser_drupal_langcode_mappings($mappings); } - $form_state['redirect'] = 'admin/config/regional/language/detection/browser'; + $form_state['redirect_route']['route_name'] = 'language.negotiation_browser'; } } diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php index 5cc3c4b9c39..d5b991dea06 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationBrowserForm.php @@ -178,7 +178,7 @@ class NegotiationBrowserForm extends ConfigFormBase { $config->setData($mappings); $config->save(); } - $form_state['redirect'] = 'admin/config/regional/language/detection'; + $form_state['redirect_route']['route_name'] = 'language.negotiation'; parent::submitForm($form, $form_state); } diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php index 835196a52f9..b688b0556c3 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationSessionForm.php @@ -33,7 +33,7 @@ class NegotiationSessionForm extends ConfigFormBase { '#description' => t('Name of the request/session parameter used to determine the desired language.'), ); - $form_state['redirect'] = 'admin/config/regional/language/detection'; + $form_state['redirect_route']['route_name'] = 'language.negotiation'; return parent::buildForm($form, $form_state); } diff --git a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php index 04e1e52e4e6..4a7adb0f74e 100644 --- a/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php +++ b/core/modules/language/lib/Drupal/language/Form/NegotiationUrlForm.php @@ -86,7 +86,7 @@ class NegotiationUrlForm extends ConfigFormBase { ); } - $form_state['redirect'] = 'admin/config/regional/language/detection'; + $form_state['redirect_route']['route_name'] = 'language.negotiation'; return parent::buildForm($form, $form_state); } diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php index 4524b2ddcff..a80fa91d2cd 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateEditForm.php @@ -231,7 +231,12 @@ class TranslateEditForm extends TranslateFormBase { // Keep the user on the current pager page. $page = $this->getRequest()->query->get('page'); if (isset($page)) { - $form_state['redirect'] = array('admin/config/regional/translate', array('query' => array('page' => $page))); + $form_state['redirect_route'] = array( + 'route_name' => 'locale.translate_page', + 'options' => array( + 'page' => $page, + ), + ); } if ($updated) { diff --git a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php index 9bc9987bab7..9018755a1d5 100644 --- a/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php +++ b/core/modules/locale/lib/Drupal/locale/Form/TranslateFilterForm.php @@ -91,7 +91,7 @@ class TranslateFilterForm extends TranslateFormBase { $_SESSION['locale_translate_filter'][$name] = $form_state['values'][$name]; } } - $form_state['redirect'] = 'admin/config/regional/translate'; + $form_state['redirect_route']['route_name'] = 'locale.translate_page'; } /** @@ -99,7 +99,7 @@ class TranslateFilterForm extends TranslateFormBase { */ public function resetForm(array &$form, array &$form_state) { $_SESSION['locale_translate_filter'] = array(); - $form_state['redirect'] = 'admin/config/regional/translate'; + $form_state['redirect_route']['route_name'] = 'locale.translate_page'; } } diff --git a/core/modules/locale/locale.bulk.inc b/core/modules/locale/locale.bulk.inc index 1a53771185f..a0eb62c1e0e 100644 --- a/core/modules/locale/locale.bulk.inc +++ b/core/modules/locale/locale.bulk.inc @@ -137,7 +137,7 @@ function locale_translate_import_form_submit($form, &$form_state) { return; } - $form_state['redirect'] = 'admin/config/regional/translate'; + $form_state['redirect_route']['route_name'] = 'locale.translate_page'; return; } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php index ac1e7fbfabb..35d074d8f42 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuDeleteForm.php @@ -97,7 +97,7 @@ class MenuDeleteForm extends EntityConfirmFormBase { * {@inheritdoc} */ public function submit(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/menu'; + $form_state['redirect_route']['route_name'] = 'menu.overview_page'; // Locked menus may not be deleted. if ($this->entity->isLocked()) { diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php index 2815a919d5c..efc9cdd31a7 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkDeleteForm.php @@ -41,7 +41,12 @@ class MenuLinkDeleteForm extends EntityConfirmFormBase { $t_args = array('%title' => $this->entity->link_title); drupal_set_message(t('The menu link %title has been deleted.', $t_args)); watchdog('menu', 'Deleted menu link %title.', $t_args, WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->entity->menu_name; + $form_state['redirect_route'] = array( + 'route_name' => 'menu.menu_edit', + 'route_parameters' => array( + 'menu' => $this->entity->menu_name, + ), + ); } } diff --git a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php index 5b79ef48c99..7542c57fb08 100644 --- a/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php +++ b/core/modules/menu/lib/Drupal/menu/Form/MenuLinkResetForm.php @@ -53,7 +53,12 @@ class MenuLinkResetForm extends EntityConfirmFormBase { public function submit(array $form, array &$form_state) { $new_menu_link = $this->entity->reset(); drupal_set_message(t('The menu link was reset to its default settings.')); - $form_state['redirect'] = 'admin/structure/menu/manage/' . $new_menu_link->menu_name; + $form_state['redirect_route'] = array( + 'route_name' => 'menu.menu_edit', + 'route_parameters' => array( + 'menu' => $new_menu_link->menu_name, + ), + ); } } diff --git a/core/modules/menu/lib/Drupal/menu/MenuFormController.php b/core/modules/menu/lib/Drupal/menu/MenuFormController.php index 8d9ca2612b7..5e369d515ff 100644 --- a/core/modules/menu/lib/Drupal/menu/MenuFormController.php +++ b/core/modules/menu/lib/Drupal/menu/MenuFormController.php @@ -215,14 +215,24 @@ class MenuFormController extends EntityFormController { watchdog('menu', 'Menu %label has been added.', array('%label' => $menu->label()), WATCHDOG_NOTICE, l(t('Edit'), $uri['path'] . '/edit')); } - $form_state['redirect'] = 'admin/structure/menu/manage/' . $menu->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'menu.menu_edit', + 'route_parameters' => array( + 'menu' => $this->entity->id(), + ), + ); } /** * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/menu/manage/' . $this->entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'menu.delete_menu', + 'route_parameters' => array( + 'menu' => $this->entity->id(), + ), + ); } /** diff --git a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php index 3222a68e092..ef70affa9fd 100644 --- a/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php +++ b/core/modules/menu_link/lib/Drupal/menu_link/MenuLinkFormController.php @@ -297,7 +297,12 @@ class MenuLinkFormController extends EntityFormController { if ($saved) { drupal_set_message(t('The menu link has been saved.')); - $form_state['redirect'] = 'admin/structure/menu/manage/' . $menu_link->menu_name; + $form_state['redirect_route'] = array( + 'route_name' => 'menu.menu_edit', + 'route_parameters' => array( + 'menu' => $menu_link->menu_name, + ), + ); } else { drupal_set_message(t('There was an error saving the menu link.'), 'error'); @@ -310,6 +315,11 @@ class MenuLinkFormController extends EntityFormController { */ public function delete(array $form, array &$form_state) { $menu_link = $this->entity; - $form_state['redirect'] = 'admin/structure/menu/item/' . $menu_link->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'menu.link_delete', + 'route_parameters' => array( + 'menu' => $menu_link->id(), + ), + ); } } diff --git a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php index 52e4dfbfb3b..c8470046579 100644 --- a/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php +++ b/core/modules/node/lib/Drupal/node/Form/DeleteMultiple.php @@ -126,7 +126,7 @@ class DeleteMultiple extends ConfirmFormBase implements ContainerInjectionInterf drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.')); Cache::invalidateTags(array('content' => TRUE)); } - $form_state['redirect'] = 'admin/content'; + $form_state['redirect_route']['route_name'] = 'node.content_overview'; } } diff --git a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php index 51da0371d34..644b0692528 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeDeleteForm.php @@ -91,7 +91,7 @@ class NodeDeleteForm extends ContentEntityConfirmFormBase { $node_type = $node_type_storage->load($this->entity->bundle())->label(); drupal_set_message(t('@type %title has been deleted.', array('@type' => $node_type, '%title' => $this->entity->label()))); Cache::invalidateTags(array('content' => TRUE)); - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } } diff --git a/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php b/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php index 1ce40f77028..99edd0e6c17 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeRevisionDeleteForm.php @@ -123,9 +123,14 @@ class NodeRevisionDeleteForm extends ConfirmFormBase implements ContainerInjecti watchdog('content', '@type: deleted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId())); $node_type = $this->nodeTypeStorage->load($this->revision->bundle())->label(); drupal_set_message(t('Revision from %revision-date of @type %title has been deleted.', array('%revision-date' => format_date($this->revision->getRevisionCreationTime()), '@type' => $node_type, '%title' => $this->revision->label()))); - $form_state['redirect'] = 'node/' . $this->revision->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'node.view', + 'route_parameters' => array( + 'node' => $this->revision->id(), + ), + ); if ($this->connection->query('SELECT COUNT(DISTINCT vid) FROM {node_field_revision} WHERE nid = :nid', array(':nid' => $this->revision->id()))->fetchField() > 1) { - $form_state['redirect'] .= '/revisions'; + $form_state['redirect_route']['route_name'] = 'node.revision_overview'; } } diff --git a/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php b/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php index 72f6dc53800..12cb9e38531 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeRevisionRevertForm.php @@ -115,7 +115,12 @@ class NodeRevisionRevertForm extends ConfirmFormBase implements ContainerInjecti watchdog('content', '@type: reverted %title revision %revision.', array('@type' => $this->revision->bundle(), '%title' => $this->revision->label(), '%revision' => $this->revision->getRevisionId())); drupal_set_message(t('@type %title has been reverted back to the revision from %revision-date.', array('@type' => node_get_type_label($this->revision), '%title' => $this->revision->label(), '%revision-date' => format_date($original_revision_timestamp)))); - $form_state['redirect'] = 'node/' . $this->revision->id() . '/revisions'; + $form_state['redirect_route'] = array( + 'route_name' => 'node.revision_overview', + 'route_parameters' => array( + 'node' => $this->revision->id(), + ), + ); } } diff --git a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php index 06c5766501f..8adc5754e4a 100644 --- a/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php +++ b/core/modules/node/lib/Drupal/node/Form/NodeTypeDeleteConfirm.php @@ -89,7 +89,7 @@ class NodeTypeDeleteConfirm extends EntityConfirmFormBase { drupal_set_message(t('The content type %name has been deleted.', $t_args)); watchdog('node', 'Deleted content type %name.', $t_args, WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/types'; + $form_state['redirect_route']['route_name'] = 'node.overview_types'; } } diff --git a/core/modules/node/lib/Drupal/node/Form/RebuildPermissionsForm.php b/core/modules/node/lib/Drupal/node/Form/RebuildPermissionsForm.php index cd12cb5dd73..ee70dfd1c19 100644 --- a/core/modules/node/lib/Drupal/node/Form/RebuildPermissionsForm.php +++ b/core/modules/node/lib/Drupal/node/Form/RebuildPermissionsForm.php @@ -53,7 +53,7 @@ class RebuildPermissionsForm extends ConfirmFormBase { */ public function submitForm(array &$form, array &$form_state) { node_access_rebuild(TRUE); - $form_state['redirect'] = 'admin/reports/status'; + $form_state['redirect_route']['route_name'] = 'system.status'; } } diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index e14a6623942..659777a3481 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -482,7 +482,17 @@ class NodeFormController extends ContentEntityFormController { if ($node->id()) { $form_state['values']['nid'] = $node->id(); $form_state['nid'] = $node->id(); - $form_state['redirect'] = node_access('view', $node) ? 'node/' . $node->id() : ''; + if ($node->access('view')) { + $form_state['redirect_route'] = array( + 'route_name' => 'node.view', + 'route_parameters' => array( + 'node' => $node->id(), + ), + ); + } + else { + $form_state['redirect_route']['route_name'] = ''; + } } else { // In the unlikely case something went wrong on save, the node will be @@ -505,8 +515,15 @@ class NodeFormController extends ContentEntityFormController { $destination = drupal_get_destination(); $query->remove('destination'); } - $node = $this->entity; - $form_state['redirect'] = array('node/' . $node->id() . '/delete', array('query' => $destination)); + $form_state['redirect_route'] = array( + 'route_name' => 'node.delete_confirm', + 'route_parameters' => array( + 'node' => $this->entity->id(), + ), + 'options' => array( + 'query' => $destination, + ), + ); } } diff --git a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php index a385b200b68..ef94963aca2 100644 --- a/core/modules/node/lib/Drupal/node/NodeTypeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeTypeFormController.php @@ -236,14 +236,19 @@ class NodeTypeFormController extends EntityFormController { watchdog('node', 'Added content type %name.', $t_args, WATCHDOG_NOTICE, l(t('view'), 'admin/structure/types')); } - $form_state['redirect'] = 'admin/structure/types'; + $form_state['redirect_route']['route_name'] = 'node.overview_types'; } /** * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/types/manage/' . $this->entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'node.type_delete_confirm', + 'route_parameters' => array( + 'node_type' => $this->entity->id(), + ), + ); } } diff --git a/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php b/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php index 26983be5f2c..ba47dd0a569 100644 --- a/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php +++ b/core/modules/picture/lib/Drupal/picture/Form/PictureMappingDeleteForm.php @@ -41,7 +41,7 @@ class PictureMappingDeleteForm extends EntityConfirmFormBase { $this->entity->delete(); drupal_set_message(t('Picture mapping %label has been deleted.', array('%label' => $this->entity->label()))); watchdog('picture', 'Picture mapping %label has been deleted.', array('%label' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/config/media/picturemapping'; + $form_state['redirect_route']['route_name'] = 'picture.mapping_page'; } } diff --git a/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php b/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php index b7831c2b761..00f5b9f09a8 100644 --- a/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php +++ b/core/modules/picture/lib/Drupal/picture/PictureMappingFormController.php @@ -143,11 +143,15 @@ class PictureMappingFormController extends EntityFormController { // Redirect to edit form after creating a new mapping or after selecting // another breakpoint group. if (!$picture_mapping->hasMappings()) { - $uri = $picture_mapping->uri(); - $form_state['redirect'] = $uri['path']; + $form_state['redirect_route'] = array( + 'route_name' => 'picture.mapping_page_edit', + 'route_parameters' => array( + 'picture_mapping' => $picture_mapping->id(), + ), + ); } else { - $form_state['redirect'] = 'admin/config/media/picturemapping'; + $form_state['redirect_route']['route_name'] = 'picture.mapping_page'; } } diff --git a/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php b/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php index c8654897e51..f4ed6de7d1b 100644 --- a/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php +++ b/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php @@ -65,8 +65,7 @@ class ReindexConfirm extends ConfirmFormBase { if ($form['confirm']) { search_reindex(); drupal_set_message($this->t('The index will be rebuilt.')); - $form_state['redirect'] = 'admin/config/search/settings'; - return; + $form_state['redirect_route']['route_name'] = 'search.settings'; } } } diff --git a/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php b/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php index 1ef184102be..c2f14e7019f 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchBlockForm.php @@ -64,7 +64,12 @@ class SearchBlockForm extends FormBase { $form_id = $form['form_id']['#value']; $info = search_get_default_plugin_info(); if ($info) { - $form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]); + $form_state['redirect_route'] = array( + 'route_name' => 'search.view_' . $info['id'], + 'route_parameters' => array( + 'keys' => trim($form_state['values'][$form_id]), + ), + ); } else { form_set_error(NULL, $this->t('Search is currently disabled.'), 'error'); diff --git a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php index 68876e222c5..0bf795a9aaa 100644 --- a/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php +++ b/core/modules/search/lib/Drupal/search/Form/SearchSettingsForm.php @@ -273,7 +273,7 @@ class SearchSettingsForm extends ConfigFormBase { */ public function searchAdminReindexSubmit(array $form, array &$form_state) { // send the user to the confirmation page - $form_state['redirect'] = 'admin/config/search/settings/reindex'; + $form_state['redirect_route']['route_name'] = 'search.reindex_confirm'; } } diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 3fc29530a22..56e6859f2aa 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -639,63 +639,6 @@ function search_mark_for_reindex($type, $sid) { * can easily find it. */ -/** - * Form constructor for the search block's search box. - * - * @param $form_id - * The unique string identifying the desired form. - * - * @see search_box_form_submit() - * - * @ingroup forms - */ -function search_box($form, &$form_state, $form_id) { - $form[$form_id] = array( - '#type' => 'search', - '#title' => t('Search'), - '#title_display' => 'invisible', - '#size' => 15, - '#default_value' => '', - '#attributes' => array('title' => t('Enter the terms you wish to search for.')), - ); - $form['actions'] = array('#type' => 'actions'); - $form['actions']['submit'] = array('#type' => 'submit', '#value' => t('Search')); - $form['#submit'][] = 'search_box_form_submit'; - - return $form; -} - -/** - * Form submission handler for search_box(). - */ -function search_box_form_submit($form, &$form_state) { - // The search form relies on control of the redirect destination for its - // functionality, so we override any static destination set in the request. - // See http://drupal.org/node/292565. - if (isset($_GET['destination'])) { - unset($_GET['destination']); - } - - // Check to see if the form was submitted empty. - // If it is empty, display an error message. - // (This method is used instead of setting #required to TRUE for this field - // because that results in a confusing error message. It would say a plain - // "field is required" because the search keywords field has no title. - // The error message would also complain about a missing #title field.) - if ($form_state['values']['search_block_form'] == '') { - form_set_error('keys', t('Please enter some keywords.')); - } - - $form_id = $form['form_id']['#value']; - $info = search_get_default_plugin_info(); - if ($info) { - $form_state['redirect'] = 'search/' . $info['path'] . '/' . trim($form_state['values'][$form_id]); - } - else { - form_set_error(NULL, t('Search is currently disabled.'), 'error'); - } -} - /** * Returns snippets from a piece of text, with certain keywords highlighted. * diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php index 555308d9ae1..5f500960969 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/LinkDelete.php @@ -70,7 +70,12 @@ class LinkDelete extends ConfirmFormBase { public function submitForm(array &$form, array &$form_state) { menu_link_delete($this->menuLink->mlid); $set_name = str_replace('shortcut-', '' , $this->menuLink->menu_name); - $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $set_name; + $form_state['redirect_route'] = array( + 'route_name' => 'shortcut.set_customize', + 'route_parameters' => array( + 'shortcut_set' => $set_name, + ), + ); drupal_set_message(t('The shortcut %title has been deleted.', array('%title' => $this->menuLink->link_title))); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php index d7cdd9ae6d8..0b97dede8f6 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutSetDeleteForm.php @@ -107,7 +107,7 @@ class ShortcutSetDeleteForm extends EntityConfirmFormBase { */ public function submit(array $form, array &$form_state) { $this->entity->delete(); - $form_state['redirect'] = 'admin/config/user-interface/shortcut'; + $form_state['redirect_route']['route_name'] = 'shortcut.set_admin'; drupal_set_message(t('The shortcut set %title has been deleted.', array('%title' => $this->entity->label()))); } diff --git a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetFormController.php b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetFormController.php index 21b322381d4..8f89a059880 100644 --- a/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetFormController.php +++ b/core/modules/shortcut/lib/Drupal/shortcut/ShortcutSetFormController.php @@ -83,15 +83,24 @@ class ShortcutSetFormController extends EntityFormController { else { drupal_set_message(t('Updated set name to %set-name.', array('%set-name' => $entity->label()))); } - $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'shortcut.set_customize', + 'route_parameters' => array( + 'shortcut_set' => $this->entity->id(), + ), + ); } /** * Overrides \Drupal\Core\Entity\EntityFormController::delete(). */ public function delete(array $form, array &$form_state) { - $entity = $this->entity; - $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'shortcut.set_delete', + 'route_parameters' => array( + 'shortcut_set' => $this->entity->id(), + ), + ); } } diff --git a/core/modules/shortcut/shortcut.admin.inc b/core/modules/shortcut/shortcut.admin.inc index 41214bc2621..ab998a7f64e 100644 --- a/core/modules/shortcut/shortcut.admin.inc +++ b/core/modules/shortcut/shortcut.admin.inc @@ -158,7 +158,12 @@ function shortcut_set_switch_submit($form, &$form_state) { else { drupal_set_message(t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements)); } - $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $set->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'shortcut.set_customize', + 'route_parameters' => array( + 'shortcut_set' => $set->id(), + ), + ); } else { // Switch to a different shortcut set. @@ -310,7 +315,12 @@ function shortcut_link_edit_submit($form, &$form_state) { menu_link_save($shortcut_link); $set_name = str_replace('shortcut-', '' , $shortcut_link['menu_name']); - $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $set_name; + $form_state['redirect_route'] = array( + 'route_name' => 'shortcut.set_customize', + 'route_parameters' => array( + 'shortcut_set' => $set_name, + ), + ); drupal_set_message(t('The shortcut %link has been updated.', array('%link' => $shortcut_link['link_title']))); } @@ -324,7 +334,12 @@ function shortcut_link_add_submit($form, &$form_state) { $shortcut_link['menu_name'] = $shortcut_set->id(); shortcut_admin_add_link($shortcut_link, $shortcut_set); $shortcut_set->save(); - $form_state['redirect'] = 'admin/config/user-interface/shortcut/manage/' . $shortcut_set->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'shortcut.set_customize', + 'route_parameters' => array( + 'shortcut_set' => $shortcut_set->id(), + ), + ); drupal_set_message(t('Added a shortcut for %title.', array('%title' => $shortcut_link['link_title']))); } diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php index b6ec3767402..8a907f031de 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestResultsForm.php @@ -251,7 +251,7 @@ class SimpletestResultsForm extends FormBase { } if (!$classes) { - $form_state['redirect'] = 'admin/config/development/testing'; + $form_state['redirect_route']['route_name'] = 'simpletest.test_form'; return; } @@ -264,7 +264,7 @@ class SimpletestResultsForm extends FormBase { // Submit the simpletest test form to rerun the tests. $simpletest_test_form = new SimpletestTestForm(); $simpletest_test_form->submitForm($form_execute, $form_state_execute); - $form_state['redirect'] = $form_state_execute['redirect']; + $form_state['redirect_route'] = $form_state_execute['redirect_route']; } /** diff --git a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php index 5ba6734807a..c469b52a39d 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/Form/SimpletestTestForm.php @@ -113,7 +113,12 @@ class SimpletestTestForm extends FormBase { } if (count($tests_list) > 0 ) { $test_id = simpletest_run_tests($tests_list, 'drupal'); - $form_state['redirect'] = 'admin/config/development/testing/results/' . $test_id; + $form_state['redirect_route'] = array( + 'route_name' => 'simpletest.result_form', + 'route_parameters' => array( + 'test_id' => $test_id, + ), + ); } else { drupal_set_message($this->t('No test(s) selected.'), 'error'); diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php index 619a9203c9a..79629fa590d 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatDeleteForm.php @@ -75,7 +75,7 @@ class DateFormatDeleteForm extends EntityConfirmFormBase { $this->entity->delete(); drupal_set_message(t('Removed date format %format.', array('%format' => $this->entity->label()))); - $form_state['redirect'] = 'admin/config/regional/date-time'; + $form_state['redirect_route']['route_name'] = 'system.date_format_list'; } } diff --git a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php index cc283af22a3..3b6f347c9e6 100644 --- a/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php +++ b/core/modules/system/lib/Drupal/system/Form/DateFormatFormBase.php @@ -201,7 +201,7 @@ abstract class DateFormatFormBase extends EntityFormController { * {@inheritdoc} */ public function submit(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/config/regional/date-time'; + $form_state['redirect_route']['route_name'] = 'system.date_format_list'; $form_state['values']['pattern'][$this->patternType] = trim($form_state['values']['date_format_pattern']); parent::submit($form, $form_state); diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php index ccab5b1dda4..3f5ae9fbb63 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListConfirmForm.php @@ -153,7 +153,7 @@ class ModulesListConfirmForm extends ConfirmFormBase implements ContainerInjecti drupal_set_message($this->t('The configuration options have been saved.')); } - $form_state['redirect'] = 'admin/modules'; + $form_state['redirect_route']['route_name'] = 'system.modules_list'; } } diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php index 5566b28c08d..a090c67b215 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesListForm.php @@ -392,7 +392,7 @@ class ModulesListForm extends FormBase { $this->keyValueExpirable->setWithExpire($account, $modules, 60); // Redirect to the confirmation form. - $form_state['redirect'] = 'admin/modules/list/confirm'; + $form_state['redirect_route']['route_name'] = 'system.modules_list_confirm'; // We can exit here because at least one modules has dependencies // which we have to prompt the user for in a confirmation form. diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php index efc31c19e2f..1a85d9e55cf 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallConfirmForm.php @@ -137,7 +137,7 @@ class ModulesUninstallConfirmForm extends ConfirmFormBase implements ContainerIn $this->moduleHandler->uninstall($this->modules); drupal_set_message($this->t('The selected modules have been uninstalled.')); - $form_state['redirect'] = 'admin/modules/uninstall'; + $form_state['redirect_route']['route_name'] = 'system.modules_uninstall'; } } diff --git a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php index ed9206431e2..711f934fff8 100644 --- a/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php +++ b/core/modules/system/lib/Drupal/system/Form/ModulesUninstallForm.php @@ -129,7 +129,7 @@ class ModulesUninstallForm extends FormBase { // Form submitted, but no modules selected. if (!array_filter($form_state['values']['uninstall'])) { drupal_set_message($this->t('No modules selected.'), 'error'); - $form_state['redirect'] = 'admin/modules/uninstall'; + $form_state['redirect_route']['route_name'] = 'system.modules_uninstall'; } } @@ -144,6 +144,6 @@ class ModulesUninstallForm extends FormBase { $this->keyValueExpirable->setWithExpire($account, $uninstall, 60); // Redirect to the confirm form. - $form_state['redirect'] = 'admin/modules/uninstall/confirm'; + $form_state['redirect_route']['route_name'] = 'system.modules_uninstall_confirm'; } } diff --git a/core/modules/system/tests/modules/ajax_test/ajax_test.module b/core/modules/system/tests/modules/ajax_test/ajax_test.module index 802b34e757e..f42844fb7f0 100644 --- a/core/modules/system/tests/modules/ajax_test/ajax_test.module +++ b/core/modules/system/tests/modules/ajax_test/ajax_test.module @@ -213,7 +213,7 @@ function ajax_test_dialog_form($form, &$form_state) { * Non-AJAX behavior of the dialog buttons. */ function ajax_test_dialog_form_submit($form, &$form_state) { - $form_state['redirect'] = 'ajax-test/dialog-contents'; + $form_state['redirect_route']['route_name'] = 'ajax_test.dialog_contents'; } /** diff --git a/core/modules/system/tests/modules/batch_test/batch_test.module b/core/modules/system/tests/modules/batch_test/batch_test.module index ff0e37fb4c1..0dbbff8e2fb 100644 --- a/core/modules/system/tests/modules/batch_test/batch_test.module +++ b/core/modules/system/tests/modules/batch_test/batch_test.module @@ -108,7 +108,7 @@ function batch_test_simple_form_submit($form, &$form_state) { $function = '_batch_test_' . $form_state['values']['batch']; batch_set($function()); - $form_state['redirect'] = 'batch-test/redirect'; + $form_state['redirect_route']['route_name'] = 'batch_test.redirect'; } @@ -158,7 +158,7 @@ function batch_test_multistep_form_submit($form, &$form_state) { } // This will only be effective on the last step. - $form_state['redirect'] = 'batch-test/redirect'; + $form_state['redirect_route']['route_name'] = 'batch_test.redirect'; } /** @@ -208,7 +208,7 @@ function batch_test_chained_form_submit_1($form, &$form_state) { batch_set(_batch_test_batch_1()); // This redirect should not be taken into account. - $form_state['redirect'] = 'should/be/discarded'; + $form_state['redirect_route']['route_name'] = 'batch_test.redirect'; } /** @@ -224,7 +224,7 @@ function batch_test_chained_form_submit_2($form, &$form_state) { batch_set(_batch_test_batch_2()); // This redirect should not be taken into account. - $form_state['redirect'] = 'should/be/discarded'; + $form_state['redirect_route']['route_name'] = 'batch_test.redirect'; } /** @@ -239,7 +239,7 @@ function batch_test_chained_form_submit_3($form, &$form_state) { $form_state['values']['value']++; // This redirect should not be taken into account. - $form_state['redirect'] = 'should/be/discarded'; + $form_state['redirect_route']['route_name'] = 'batch_test.redirect'; } /** @@ -255,7 +255,7 @@ function batch_test_chained_form_submit_4($form, &$form_state) { batch_set(_batch_test_batch_3()); // This is the redirect that should prevail. - $form_state['redirect'] = 'batch-test/redirect'; + $form_state['redirect_route']['route_name'] = 'batch_test.redirect'; } /** diff --git a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php index 7b0741d99ce..7fe28125a02 100644 --- a/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php +++ b/core/modules/system/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestFormController.php @@ -93,7 +93,13 @@ class EntityTestFormController extends ContentEntityFormController { drupal_set_message($message); if ($entity->id()) { - $form_state['redirect'] = $entity->entityType() . '/manage/' . $entity->id(); + $entity_type = $entity->entityType(); + $form_state['redirect_route'] = array( + 'route_name' => "entity_test.edit_$entity_type", + 'route_parameters' => array( + $entity_type => $entity->id(), + ), + ); } else { // Error on save. @@ -109,6 +115,6 @@ class EntityTestFormController extends ContentEntityFormController { $entity = $this->entity; $entity->delete(); drupal_set_message(t('%entity_type @id has been deleted.', array('@id' => $entity->id(), '%entity_type' => $entity->entityType()))); - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } } diff --git a/core/modules/system/tests/modules/form_test/form_test.module b/core/modules/system/tests/modules/form_test/form_test.module index a3d1cd0cff0..6c771515c53 100644 --- a/core/modules/system/tests/modules/form_test/form_test.module +++ b/core/modules/system/tests/modules/form_test/form_test.module @@ -647,7 +647,7 @@ function form_test_storage_form_submit($form, &$form_state) { if (isset($form_state['storage']['thing']['changed'])) { drupal_set_message("The thing has been changed."); } - $form_state['redirect'] = 'node'; + $form_state['redirect_route']['route_name'] = ''; } /** diff --git a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php index fe5461bfa07..43f8173af0c 100644 --- a/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php +++ b/core/modules/system/tests/modules/form_test/lib/Drupal/form_test/ConfirmFormTestForm.php @@ -72,7 +72,7 @@ class ConfirmFormTestForm extends ConfirmFormBase { */ public function submitForm(array &$form, array &$form_state) { drupal_set_message($this->t('The ConfirmFormTestForm::submitForm() method was used for this form.')); - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php index 3852ea8d186..b85d3fbf577 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/OverviewTerms.php @@ -452,7 +452,10 @@ class OverviewTerms extends FormBase { * Redirects to confirmation form for the reset action. */ public function submitReset(array &$form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $form_state['taxonomy']['vocabulary']->id() . '/reset'; + $form_state['redirect_route'] = array( + 'route_name' => 'taxonomy.vocabulary_reset', + 'route_parameters' => array('taxonomy_vocabulary' => $form_state['taxonomy']['vocabulary']->id()), + ); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php index cec3c3cc3e1..b9d810d913d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/TermDeleteForm.php @@ -67,7 +67,7 @@ class TermDeleteForm extends ContentEntityConfirmFormBase { drupal_set_message($this->t('Deleted term %name.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Deleted term %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/taxonomy'; + $form_state['redirect_route']['route_name'] = 'taxonomy.vocabulary_list'; Cache::invalidateTags(array('content' => TRUE)); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php index a2cf2ef9162..803290193d5 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyDeleteForm.php @@ -59,7 +59,7 @@ class VocabularyDeleteForm extends EntityConfirmFormBase { $this->entity->delete(); drupal_set_message($this->t('Deleted vocabulary %name.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Deleted vocabulary %name.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/taxonomy'; + $form_state['redirect_route']['route_name'] = 'taxonomy.vocabulary_list'; Cache::invalidateTags(array('content' => TRUE)); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php index e735800d340..9f9e2559d8d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Form/VocabularyResetForm.php @@ -89,7 +89,10 @@ class VocabularyResetForm extends EntityConfirmFormBase { $this->termStorage->resetWeights($this->entity->id()); drupal_set_message($this->t('Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()))); watchdog('taxonomy', 'Reset vocabulary %name to alphabetical order.', array('%name' => $this->entity->label()), WATCHDOG_NOTICE); - $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $this->entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'taxonomy.vocabulary_edit', + 'route_parameters' => array('taxonomy_vocabulary' => $this->entity->id()), + ); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php index 0dbaf6322e3..c6692aaeb08 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/TermFormController.php @@ -237,7 +237,11 @@ class TermFormController extends ContentEntityFormController { if ($this->getRequest()->query->has('destination')) { $destination = drupal_get_destination(); } - $form_state['redirect'] = array('taxonomy/term/' . $this->entity->id() . '/delete', array('query' => $destination)); + $form_state['redirect_route'] = array( + 'route_name' => 'taxonomy.term_delete', + 'route_parameters' => array('taxonomy_term' => $this->entity->id()), + 'options' => array('query' => $destination), + ); } } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php index 0a1537bd58f..05ffbf4fd8d 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyFormController.php @@ -132,13 +132,16 @@ class VocabularyFormController extends EntityFormController { case SAVED_NEW: drupal_set_message($this->t('Created new vocabulary %name.', array('%name' => $vocabulary->name))); watchdog('taxonomy', 'Created new vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/edit')); - $form_state['redirect'] = 'admin/structure/taxonomy/manage/' . $vocabulary->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'taxonomy.overview_terms', + 'route_parameters' => array('taxonomy_vocabulary' => $vocabulary->id()), + ); break; case SAVED_UPDATED: drupal_set_message($this->t('Updated vocabulary %name.', array('%name' => $vocabulary->name))); watchdog('taxonomy', 'Updated vocabulary %name.', array('%name' => $vocabulary->name), WATCHDOG_NOTICE, l($this->t('edit'), 'admin/structure/taxonomy/manage/' . $vocabulary->id() . '/edit')); - $form_state['redirect'] = 'admin/structure/taxonomy'; + $form_state['redirect_route']['route_name'] = 'taxonomy.vocabulary_list'; break; } @@ -151,7 +154,10 @@ class VocabularyFormController extends EntityFormController { */ public function delete(array $form, array &$form_state) { $vocabulary = $this->getEntity($form_state); - $form_state['redirect'] = array('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/delete'); + $form_state['redirect_route'] = array( + 'route_name' => 'taxonomy.vocabulary_delete', + 'route_parameters' => array('taxonomy_vocabulary' => $vocabulary->id()), + ); } } diff --git a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php index 59d6145f458..e1a3c6a5449 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserCancelForm.php @@ -159,7 +159,7 @@ class UserCancelForm extends ContentEntityConfirmFormBase { if ($this->currentUser()->hasPermission('administer users') && empty($form_state['values']['user_cancel_confirm']) && $this->entity->id() != $this->currentUser()->id()) { user_cancel($form_state['values'], $this->entity->id(), $form_state['values']['user_cancel_method']); - $form_state['redirect'] = 'admin/people'; + $form_state['redirect_route']['route_name'] = 'user.admin_account'; } else { // Store cancelling method and whether to notify the user in @@ -171,7 +171,10 @@ class UserCancelForm extends ContentEntityConfirmFormBase { drupal_set_message($this->t('A confirmation request to cancel your account has been sent to your e-mail address.')); watchdog('user', 'Sent account cancellation request to %name %email.', array('%name' => $this->entity->label(), '%email' => '<' . $this->entity->getEmail() . '>'), WATCHDOG_NOTICE); - $form_state['redirect'] = 'user/' . $this->entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'user.view', + 'route_parameters' => array('user' => $this->entity->id()), + ); } } diff --git a/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php b/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php index b01887b9600..aa0228d090d 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserLoginForm.php @@ -104,7 +104,10 @@ class UserLoginForm extends FormBase { */ public function submitForm(array &$form, array &$form_state) { $account = $this->userStorage->load($form_state['uid']); - $form_state['redirect'] = 'user/' . $account->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'user.view', + 'route_parameters' => array('user' => $account->id()), + ); user_login_finalize($account); } diff --git a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php index 0310d411750..ba85502e908 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserMultipleCancelConfirm.php @@ -210,7 +210,7 @@ class UserMultipleCancelConfirm extends ConfirmFormBase { } } } - $form_state['redirect'] = 'admin/people'; + $form_state['redirect_route']['route_name'] = 'user.admin_account'; } } diff --git a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php index e519b8ec358..af229436662 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php +++ b/core/modules/user/lib/Drupal/user/Form/UserPasswordForm.php @@ -137,7 +137,7 @@ class UserPasswordForm extends FormBase { drupal_set_message($this->t('Further instructions have been sent to your e-mail address.')); } - $form_state['redirect'] = 'user'; + $form_state['redirect_route']['route_name'] = 'user.page'; } } diff --git a/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php b/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php index 5aca6c72a80..bbb361469a2 100644 --- a/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php +++ b/core/modules/user/lib/Drupal/user/Form/UserRoleDelete.php @@ -44,7 +44,7 @@ class UserRoleDelete extends EntityConfirmFormBase { $this->entity->delete(); watchdog('user', 'Role %name has been deleted.', array('%name' => $this->entity->label())); drupal_set_message($this->t('Role %name has been deleted.', array('%name' => $this->entity->label()))); - $form_state['redirect'] = 'admin/people/roles'; + $form_state['redirect_route']['route_name'] = 'user.role_list'; } } diff --git a/core/modules/user/lib/Drupal/user/ProfileFormController.php b/core/modules/user/lib/Drupal/user/ProfileFormController.php index ee4f8c3144b..3c36981a827 100644 --- a/core/modules/user/lib/Drupal/user/ProfileFormController.php +++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php @@ -61,7 +61,11 @@ class ProfileFormController extends AccountFormController { $query->remove('destination'); } // We redirect from user/%/edit to user/%/cancel to make the tabs disappear. - $form_state['redirect'] = array('user/' . $this->entity->id() . '/cancel', array('query' => $destination)); + $form_state['redirect_route'] = array( + 'route_name' => 'user.cancel', + 'route_parameters' => array('user' => $this->entity->id()), + 'options' => array('query' => $destination), + ); } } diff --git a/core/modules/user/lib/Drupal/user/RegisterFormController.php b/core/modules/user/lib/Drupal/user/RegisterFormController.php index 6ace140a360..38612a27b6b 100644 --- a/core/modules/user/lib/Drupal/user/RegisterFormController.php +++ b/core/modules/user/lib/Drupal/user/RegisterFormController.php @@ -116,7 +116,7 @@ class RegisterFormController extends AccountFormController { _user_mail_notify('register_no_approval_required', $account); user_login_finalize($account); drupal_set_message($this->t('Registration successful. You are now logged in.')); - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } // No administrator approval required. elseif ($account->isActive() || $notify) { @@ -131,7 +131,7 @@ class RegisterFormController extends AccountFormController { } else { drupal_set_message($this->t('A welcome message with further instructions has been sent to your e-mail address.')); - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } } } @@ -140,7 +140,7 @@ class RegisterFormController extends AccountFormController { else { _user_mail_notify('register_pending_approval', $account); drupal_set_message($this->t('Thank you for applying for an account. Your account is currently pending approval by the site administrator.
In the meantime, a welcome message with further instructions has been sent to your e-mail address.')); - $form_state['redirect'] = ''; + $form_state['redirect_route']['route_name'] = ''; } } } diff --git a/core/modules/user/lib/Drupal/user/RoleFormController.php b/core/modules/user/lib/Drupal/user/RoleFormController.php index edb242e9751..01076dd8c66 100644 --- a/core/modules/user/lib/Drupal/user/RoleFormController.php +++ b/core/modules/user/lib/Drupal/user/RoleFormController.php @@ -75,14 +75,17 @@ class RoleFormController extends EntityFormController { drupal_set_message($this->t('Role %label has been added.', array('%label' => $entity->label()))); watchdog('user', 'Role %label has been added.', array('%label' => $entity->label()), WATCHDOG_NOTICE, l($this->t('Edit'), $uri['path'])); } - $form_state['redirect'] = 'admin/people/roles'; + $form_state['redirect_route']['route_name'] = 'user.role_list'; } /** * {@inheritdoc} */ public function delete(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/people/roles/manage/' . $this->entity->id() . '/delete'; + $form_state['redirect_route'] = array( + 'route_name' => 'user.role_delete', + 'route_parameters' => array('user_role' => $this->entity->id()), + ); } } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Analyze.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Analyze.php index 6214e9bf6bd..cc798fe0439 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Analyze.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/Ajax/Analyze.php @@ -58,7 +58,10 @@ class Analyze extends ViewsFormBase { * {@inheritdoc} */ public function submitForm(array &$form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/views/view/' . $form_state['view']->id() . '/edit'; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit', + 'route_parameters' => array('view' => $form_state['view']->id()), + ); } } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php index 646488d2aa0..8d0b48dc0c7 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/Form/BreakLockForm.php @@ -116,7 +116,10 @@ class BreakLockForm extends EntityConfirmFormBase { */ public function submit(array $form, array &$form_state) { $this->tempStore->delete($this->entity->id()); - $form_state['redirect'] = 'admin/structure/views/view/' . $this->entity->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit', + 'route_parameters' => array('view' => $this->entity->id()), + ); drupal_set_message($this->t('The lock has been broken and you may now edit this view.')); } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php index 6bd54395309..5e65fd940cb 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewAddFormController.php @@ -195,12 +195,15 @@ class ViewAddFormController extends ViewFormControllerBase { // @todo Figure out whether it really makes sense to throw and catch exceptions on the wizard. catch (WizardException $e) { drupal_set_message($e->getMessage(), 'error'); - $form_state['redirect'] = 'admin/structure/views'; + $form_state['redirect_route']['route_name'] = 'views_ui.list'; return; } $view->save(); - $form_state['redirect'] = array('admin/structure/views/view/' . $view->id()); + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit', + 'route_parameters' => array('view' => $view->id()), + ); } /** @@ -212,7 +215,7 @@ class ViewAddFormController extends ViewFormControllerBase { * A reference to a keyed array containing the current state of the form. */ public function cancel(array $form, array &$form_state) { - $form_state['redirect'] = 'admin/structure/views'; + $form_state['redirect_route']['route_name'] = 'views_ui.list'; } } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php index 251dc6fc703..4580db14b14 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewDeleteFormController.php @@ -44,7 +44,7 @@ class ViewDeleteFormController extends EntityConfirmFormBase { parent::submit($form, $form_state); $this->entity->delete(); - $form_state['redirect'] = 'admin/structure/views'; + $form_state['redirect_route']['route_name'] = 'views_ui.list'; } } diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php index 5f81565ff53..6bb082e218c 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewEditFormController.php @@ -266,7 +266,10 @@ class ViewEditFormController extends ViewFormControllerBase { $displays[$new_id] = $displays[$id]; unset($displays[$id]); // Redirect the user to the renamed display to be sure that the page itself exists and doesn't throw errors. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $new_id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $id), + ); } } $view->set('display', $displays); @@ -316,7 +319,7 @@ class ViewEditFormController extends ViewFormControllerBase { // Remove this view from cache so edits will be lost. $view = $this->entity; $this->tempStore->delete($view->id()); - $form_state['redirect'] = 'admin/structure/views'; + $form_state['redirect_route']['route_name'] = 'views_ui.list'; } /** @@ -563,7 +566,10 @@ class ViewEditFormController extends ViewFormControllerBase { $view->cacheSet(); // Redirect to the top-level edit page. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $id), + ); } /** @@ -579,7 +585,10 @@ class ViewEditFormController extends ViewFormControllerBase { $view->cacheSet(); // Redirect to the top-level edit page. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $id), + ); } /** @@ -594,7 +603,10 @@ class ViewEditFormController extends ViewFormControllerBase { $view->cacheSet(); // Redirect to the top-level edit page. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $id), + ); } /** @@ -612,7 +624,10 @@ class ViewEditFormController extends ViewFormControllerBase { // Redirect to the top-level edit page. The first remaining display will // become the active display. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id(); + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit', + 'route_parameters' => array('view' => $view->id()), + ); } /** @@ -785,7 +800,10 @@ class ViewEditFormController extends ViewFormControllerBase { $view->cacheSet(); // Redirect to the new display's edit page. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $new_display_id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $new_display_id), + ); } /** @@ -804,7 +822,10 @@ class ViewEditFormController extends ViewFormControllerBase { $view->cacheSet(); // Redirect to the new display's edit page. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $display_id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $display_id), + ); } /** @@ -837,7 +858,10 @@ class ViewEditFormController extends ViewFormControllerBase { $view->cacheSet(); // Redirect to the new display's edit page. - $form_state['redirect'] = 'admin/structure/views/view/' . $view->id() . '/edit/' . $new_display_id; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit_display', + 'route_parameters' => array('view' => $view->id(), 'display_id' => $new_display_id), + ); } /** diff --git a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php index 84bfde1d6d6..61505ae653e 100644 --- a/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php +++ b/core/modules/views_ui/lib/Drupal/views_ui/ViewUI.php @@ -277,7 +277,10 @@ class ViewUI implements ViewStorageInterface { $this->cacheSet(); } - $form_state['redirect'] = 'admin/structure/views/view/' . $this->id() . '/edit'; + $form_state['redirect_route'] = array( + 'route_name' => 'views_ui.edit', + 'route_parameters' => array('view' => $this->id()), + ); } /**