From 92ba4e6dae385d20b827c454ea110b24d60f1484 Mon Sep 17 00:00:00 2001 From: Silvia Ulenberg Date: Wed, 13 Jun 2018 16:23:56 +0200 Subject: [PATCH] Use / as fallback when there is no route given --- Controller/ThemeController.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/Controller/ThemeController.php b/Controller/ThemeController.php index b80a9e7..df055e5 100644 --- a/Controller/ThemeController.php +++ b/Controller/ThemeController.php @@ -47,7 +47,7 @@ class ThemeController protected $router; /** - * @var string + * @var string|null */ protected $defaultRoute; @@ -58,9 +58,9 @@ class ThemeController * @param array $themes Available themes * @param array|null $cookieOptions The options of the cookie we look for the theme to set * @param RouterInterface $router - * @param string $defaultRoute + * @param string|null $defaultRoute */ - public function __construct(ActiveTheme $activeTheme, array $themes, array $cookieOptions = null, RouterInterface $router, $defaultRoute = '/') + public function __construct(ActiveTheme $activeTheme, array $themes, array $cookieOptions = null, RouterInterface $router, $defaultRoute = null) { $this->activeTheme = $activeTheme; $this->themes = $themes; @@ -88,7 +88,13 @@ public function switchAction(Request $request) $this->activeTheme->setName($theme); - $url = $request->headers->get('Referer', $this->router->generate($this->defaultRoute)); + if ($defaultRoute) { + $url = $request->headers->get('Referer', $this->router->generate($this->defaultRoute)); + } + else { + $url = $request->headers->get('Referer', '/'); + } + $response = new RedirectResponse($url); if (!empty($this->cookieOptions)) {