Skip to content

Commit

Permalink
Use / as fallback when there is no route given
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvia Ulenberg committed Jun 13, 2018
1 parent e961202 commit 92ba4e6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions Controller/ThemeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class ThemeController
protected $router;

/**
* @var string
* @var string|null
*/
protected $defaultRoute;

Expand All @@ -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;
Expand Down Expand Up @@ -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 {

This comment has been minimized.

Copy link
@lsmith77

lsmith77 Jun 13, 2018

Contributor

else needs to be on the previous line to be CS compliant

$url = $request->headers->get('Referer', '/');
}

$response = new RedirectResponse($url);

if (!empty($this->cookieOptions)) {
Expand Down

0 comments on commit 92ba4e6

Please sign in to comment.