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
- Subclass RedirectResponse and check the passed url. if not external make it so
- Wrap the whole thing in a service and dont use RedirectResponse directly. Apply same logic as above
- 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
, callgenerateAbsolute
- 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