Commit 744309f9 authored by webchick's avatar webchick
Browse files

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';
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment