]> git.immae.eu Git - github/wallabag/wallabag.git/blob - src/Wallabag/CoreBundle/Helper/Redirect.php
Fixed typo in "first_steps"
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / Redirect.php
1 <?php
2
3 namespace Wallabag\CoreBundle\Helper;
4
5 use Symfony\Component\Routing\Router;
6
7 /**
8 * Manage redirections to avoid redirecting to empty routes.
9 */
10 class Redirect
11 {
12 private $router;
13
14 public function __construct(Router $router)
15 {
16 $this->router = $router;
17 }
18
19 /**
20 * @param string $url URL to redirect
21 * @param string $fallback Fallback URL if $url is null
22 *
23 * @return string
24 */
25 public function to($url, $fallback = '')
26 {
27 if (null !== $url) {
28 return $url;
29 }
30
31 if ('' === $fallback) {
32 return $this->router->generate('homepage');
33 }
34
35 return $fallback;
36 }
37 }