Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 291195

Improve DX of doing a redirect

$
0
0

Problem/Motivation

In #1668866: Replace drupal_goto() with RedirectResponse we introduced the following pattern...

-          drupal_goto("node/$node->nid");
+          return new RedirectResponse(url("node/$node->nid", array('absolute' => TRUE)));

This is issue will discuss if we can improve the pattern by removing the eminently forgetable array('absolute' => TRUE)

Proposed resolution

  1. Subclass RedirectResponse and check the passed url. if not external make it so
  2. Wrap the whole thing in a service and dont use RedirectResponse directly. Apply same logic as above
  3. Add a method to Url generator. Given that most callbacks that use redirection will be converted eventually to the new routing system, with url generator injected...instead of calling generateFromPath, call generateAbsolute
  4. Provide a Base class with a redirect() method that also takes care of the dependency on the url generator service. Something like #2018411: Figure out a nice DX when working with injected translation

Viewing all articles
Browse latest Browse all 291195

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>