Fix tests

This commit is contained in:
Nicolas Lœuillet
2016-04-15 09:58:29 +02:00
parent af497a641c
commit 4086e0782e
2 changed files with 19 additions and 12 deletions

View File

@ -4,6 +4,9 @@ namespace Wallabag\CoreBundle\Helper;
use Symfony\Component\Routing\Router;
/**
* Manage redirections to avoid redirecting to empty routes.
*/
class Redirect
{
private $router;
@ -21,16 +24,14 @@ class Redirect
*/
public function to($url, $fallback = '')
{
$returnUrl = $url;
if (null === $url) {
if ('' !== $fallback) {
$returnUrl = $fallback;
} else {
$returnUrl = $this->router->generate('homepage');
}
if (null !== $url) {
return $url;
}
return $returnUrl;
if ('' === $fallback) {
return $this->router->generate('homepage');
}
return $fallback;
}
}