Commit 744309f9 authored by webchick's avatar webchick

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

parent 4217221f
......@@ -419,6 +419,7 @@ protected function getUncacheableKeys() {
'rebuild',
'rebuild_info',
'redirect',
'redirect_route',
'no_redirect',
'temporary',
// Internal properties defined by form processing.
......@@ -640,7 +641,7 @@ public function processForm($form_id, &$form, &$form_state) {
$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'];
......
......@@ -146,10 +146,13 @@ public function save(array $form, array &$form_state) {
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 @@ public function save(array $form, array &$form_state) {
* {@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()),
);
}
}
......@@ -144,7 +144,10 @@ public function submitForm(array &$form, array &$form_state) {
// 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 @@ public function submitForm(array &$form, array &$form_state) {
$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;
......
......@@ -149,10 +149,10 @@ public function submitForm(array &$form, array &$form_state) {
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);
}
......
......@@ -45,10 +45,10 @@ public function submit(array $form, array &$form_state) {
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';
}
}
......
......@@ -43,7 +43,7 @@ public function getConfirmText() {
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';
}
}
......@@ -213,7 +213,7 @@ public function submitForm(array &$form, array &$form_state) {
$new_feed->save();
}
$form_state['redirect'] = 'admin/config/services/aggregator';
$form_state['redirect_route']['route_name'] = 'aggregator.admin_overview';
}
/**
......
......@@ -121,7 +121,7 @@ public function submitForm(array &$form, array &$form_state) {
$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';
}
}
......@@ -93,7 +93,7 @@ public function submitForm(array &$form, array &$form_state) {
$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';
}
}
......@@ -183,15 +183,19 @@ public function save(array $form, array &$form_state) {
$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 @@ public function delete(array $form, array &$form_state) {
$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,
),
);
}
/**
......
......@@ -101,15 +101,19 @@ public function save(array $form, array &$form_state) {
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(),
),
);
}
}
......@@ -60,7 +60,7 @@ public function submit(array $form, array &$form_state) {
$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';
}
}
......@@ -85,7 +85,7 @@ public function buildForm(array $form, array &$form_state) {
*/
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);
}
......
......@@ -326,9 +326,15 @@ public function submit(array $form, array &$form_state) {
// 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 @@ public function submit(array $form, array &$form_state) {
*/
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(),
),
);
}
/**
......
......@@ -43,7 +43,7 @@ public function getConfirmText() {
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';
}
}
......@@ -9,18 +9,6 @@
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(),
),
);
}
......@@ -101,7 +101,12 @@ protected function actions(array $form, array &$form_state) {
* @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 @@ public function submit(array $form, array &$form_state) {
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 @@ public function submit(array $form, array &$form_state) {
* {@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(),
),
);
}
}
......@@ -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));
}
......@@ -107,7 +107,7 @@ public function buildForm(array $form, array &$form_state) {
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 @@ public function submitForm(array &$form, array &$form_state) {
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';
}
}
......@@ -39,7 +39,7 @@ public function buildForm(array $form, array &$form_state) {
* {@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';
}
}
......@@ -96,7 +96,7 @@ public function submitForm(array &$form, array &$form_state) {
}
$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())));
......
......@@ -79,15 +79,19 @@ public function save(array $form, array &$form_state) {
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(),
),
);
}
}
......@@ -43,7 +43,7 @@ public function getCancelRoute() {
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';
}
}
......@@ -121,14 +121,17 @@ public function save(array $form, array &$form_state) {
->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()),
);
}
}
......@@ -44,7 +44,7 @@ public function submit(array $form, array &$form_state) {
$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';
}
}
......@@ -212,7 +212,7 @@ public function save(array $form, array &$form_state) {
$form_state['redirect'] = array($uri['path'], $uri['options']);
}
else {
$form_state['redirect'] = '';
$form_state['redirect_route']['route_name'] = '<front>';
}
}
}
......@@ -56,8 +56,7 @@ public function submit(array $form, array &$form_state) {
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';
}
}
......@@ -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(),
),
);
}
}
......@@ -122,8 +122,7 @@ public function save(array $form, array &$form_state) {
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';
}
}
......@@ -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'],
),
);
}
}
......
......@@ -79,8 +79,12 @@ public function submit(array $form, array &$form_state) {
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
......
......@@ -202,11 +202,17 @@ public function submitForm(array &$form, array &$form_state) {
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');
......
......@@ -189,7 +189,17 @@ public function submitForm(array &$form, array &$form_state) {
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 @@ public function delete(array &$form, array &$form_state) {
$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,
),
);
}
}
......@@ -263,7 +263,7 @@ public function submit(array $form, array &$form_state) {
}
}
$form_state['redirect'] = 'admin/config/content/formats';
$form_state['redirect_route']['route_name'] = 'filter.admin_overview';
return $this->entity;
}
......
......@@ -51,7 +51,7 @@ public function submit(array $form, array &$form_state) {
$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';
}
}