use Symfony\Component\Routing\Router;
+/**
+ * Manage redirections to avoid redirecting to empty routes.
+ */
class Redirect
{
private $router;
*/
public function to($url, $fallback = '')
{
- $returnUrl = $url;
+ if (null !== $url) {
+ return $url;
+ }
- if (null === $url) {
- if ('' !== $fallback) {
- $returnUrl = $fallback;
- } else {
- $returnUrl = $this->router->generate('homepage');
- }
+ if ('' === $fallback) {
+ return $this->router->generate('homepage');
}
- return $returnUrl;
+ return $fallback;
}
}