Issue #2125253 by tim.plunkett: Convert ()['redirect'] to ()['redirect_route()'].

8.0.x
webchick 2013-11-13 21:31:49 -08:00
parent 4217221f94
commit 744309f9f2
110 changed files with 494 additions and 268 deletions

View File

@ -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'];

View File

@ -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()),
);
}
}

View File

@ -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;

View File

@ -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);
}

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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';
}
/**

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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,
),
);
}
/**

View File

@ -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(),
),
);
}
}

View File

@ -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';
}
}

View File

@ -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);
}

View File

@ -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(),
),
);
}
/**

View File

@ -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';
}
}

View File

@ -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(),
),
);
}

View File

@ -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(),
),
);
}
}

View File

@ -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));
}

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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 <em>@message</em>', array('@message' => $e->getMessage())));

View File

@ -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(),
),
);
}
}

View File

@ -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';
}
}

View File

@ -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()),
);
}
}

View File

@ -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';
}
}

View File

@ -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'] = '<front>';
}
}
}

View File

@ -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';
}
}

View File

@ -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(),
),
);
}
}

View File

@ -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';
}
}

View File

@ -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'],
),
);
}
}

View File

@ -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

View File

@ -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');

View File

@ -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,
),
);
}
}

View File

@ -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;
}

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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,
),
);
}

View File

@ -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(),
),
);
}
}

View File

@ -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(),
),
);
}
/**

View File

@ -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';
}
}

View File

@ -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 {

View File

@ -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';
}
}

View File

@ -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();
}

View File

@ -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.'));
}

View File

@ -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 <a href="@block-admin">block administration page</a>.', array('@block-admin' => url('admin/structure/block'))));
$form_state['redirect'] = 'admin/config/regional/language';
$form_state['redirect_route']['route_name'] = 'language.admin_overview';
}
/**

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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);
}

View File

@ -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) {

View File

@ -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';
}
}

View File

@ -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;
}

View File

@ -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()) {

View File

@ -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,
),
);
}
}

View File

@ -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,
),
);
}
}

View File

@ -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(),
),
);
}
/**

View File

@ -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(),
),
);
}
}

View File

@ -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';
}
}

View File

@ -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'] = '<front>';
$form_state['redirect_route']['route_name'] = '<front>';
}
}

View File

@ -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';
}
}

View File

@ -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(),
),
);
}
}

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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() : '<front>';
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'] = '<front>';
}
}
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,
),
);
}
}

View File

@ -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(),
),
);
}
}

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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';
}
}
}

View File

@ -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');

View File

@ -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';
}
}

View File

@ -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.
*

View File

@ -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)));
}

View File

@ -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())));
}

View File

@ -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(),
),
);
}
}

View File

@ -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'])));
}

View File

@ -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'];
}
/**

View File

@ -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');

View File

@ -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';
}
}

View File

@ -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);

View File

@ -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';
}
}

View File

@ -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.

View File

@ -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';
}
}

View File

@ -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';
}
}

View File

@ -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';
}
/**

View File

@ -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';
}
/**

View File

@ -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'] = '<front>';
$form_state['redirect_route']['route_name'] = '<front>';
}
}

View File

@ -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'] = '<front>';
}
/**

View File

@ -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'] = '<front>';
}
}

View File

@ -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()),
);
}
}

View File

@ -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));
}

View File

@ -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));
}

View File

@ -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()),
);
}
}

View File

@ -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),
);
}
}

View File

@ -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()),
);
}
}

View File

@ -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()),
);
}
}

View File

@ -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);
}

View File

@ -210,7 +210,7 @@ class UserMultipleCancelConfirm extends ConfirmFormBase {
}
}
}
$form_state['redirect'] = 'admin/people';
$form_state['redirect_route']['route_name'] = 'user.admin_account';
}
}

View File

@ -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';
}
}

Some files were not shown because too many files have changed in this diff Show More