Skip to main content
added 88 characters in body
Source Link
AKS
  • 9.6k
  • 28
  • 63

drupal_goto is removed in favor of RedirectResponse (record).

As of Drupal 8 drupal_goto() has been removed in favor of RedirectResponse which comes together with the Symfony HttpFoundation.

hook_drupal_goto_alter() was also removed as well, in favor of just using an event listener on kernel.response

Drupal 7

<?php
function my_menu_callback_foo() {
  //....
  drupal_goto('user');
}
?>

Drupal 8 (procedural)

<?php
function my_menu_callback_foo() {
  /$url = Url::createFromPath('node/....1');
  return new RedirectResponse(\Drupal::url$url->toString('user.page'));
 //Or try this:
 return new RedirectResponse('node/1');
}
?>

drupal_goto is removed in favor of RedirectResponse (record).

As of Drupal 8 drupal_goto() has been removed in favor of RedirectResponse which comes together with the Symfony HttpFoundation.

hook_drupal_goto_alter() was also removed as well, in favor of just using an event listener on kernel.response

Drupal 7

<?php
function my_menu_callback_foo() {
  //....
  drupal_goto('user');
}
?>

Drupal 8 (procedural)

<?php
function my_menu_callback_foo() {
  //....
  return new RedirectResponse(\Drupal::url('user.page'));
}
?>

drupal_goto is removed in favor of RedirectResponse (record).

As of Drupal 8 drupal_goto() has been removed in favor of RedirectResponse which comes together with the Symfony HttpFoundation.

hook_drupal_goto_alter() was also removed as well, in favor of just using an event listener on kernel.response

Drupal 7

<?php
function my_menu_callback_foo() {
  //....
  drupal_goto('user');
}
?>

Drupal 8 (procedural)

<?php
function my_menu_callback_foo() {
  $url = Url::createFromPath('node/1');
  return new RedirectResponse($url->toString());
 //Or try this:
 return new RedirectResponse('node/1');
}
?>
Source Link
AKS
  • 9.6k
  • 28
  • 63

drupal_goto is removed in favor of RedirectResponse (record).

As of Drupal 8 drupal_goto() has been removed in favor of RedirectResponse which comes together with the Symfony HttpFoundation.

hook_drupal_goto_alter() was also removed as well, in favor of just using an event listener on kernel.response

Drupal 7

<?php
function my_menu_callback_foo() {
  //....
  drupal_goto('user');
}
?>

Drupal 8 (procedural)

<?php
function my_menu_callback_foo() {
  //....
  return new RedirectResponse(\Drupal::url('user.page'));
}
?>