From: Nicolas LÅ“uillet Date: Tue, 6 Oct 2015 18:51:40 +0000 (+0200) Subject: fix bug on detect active theme X-Git-Tag: 2.0.0-alpha.1~26^2 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=ce782c84b85f23c6c6a47cd044694f48377e8416;p=github%2Fwallabag%2Fwallabag.git fix bug on detect active theme --- 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')); } }