From ce782c84b85f23c6c6a47cd044694f48377e8416 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nicolas=20L=C5=93uillet?= Date: Tue, 6 Oct 2015 20:51:40 +0200 Subject: [PATCH] fix bug on detect active theme --- src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php | 8 +++++++- .../CoreBundle/Tests/Twig/WallabagExtensionTest.php | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php index 679186c0..054a3752 100644 --- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php +++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php @@ -42,7 +42,13 @@ class DetectActiveTheme implements DeviceDetectionInterface */ public function getType() { - $user = $this->securityContext->getToken()->getUser(); + $token = $this->securityContext->getToken(); + + if (is_null($token)) { + return $this->defaultTheme; + } + + $user = $token->getUser(); if (!$user instanceof User) { return $this->defaultTheme; diff --git a/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php b/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php index 4945e9a9..9af8fad8 100644 --- a/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php +++ b/src/Wallabag/CoreBundle/Tests/Twig/WallabagExtensionTest.php @@ -10,8 +10,8 @@ class WallabagExtensionTest extends \PHPUnit_Framework_TestCase { $extension = new WallabagExtension(); - $this->assertEquals("lemonde.fr", $extension->removeWww('www.lemonde.fr')); - $this->assertEquals("lemonde.fr", $extension->removeWww('lemonde.fr')); - $this->assertEquals("gist.github.com", $extension->removeWww('gist.github.com')); + $this->assertEquals('lemonde.fr', $extension->removeWww('www.lemonde.fr')); + $this->assertEquals('lemonde.fr', $extension->removeWww('lemonde.fr')); + $this->assertEquals('gist.github.com', $extension->removeWww('gist.github.com')); } } -- 2.41.0