aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php')
-rw-r--r--src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
index 9f90ee3e..f1d5fdea 100644
--- a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
+++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
@@ -16,15 +16,18 @@ class DetectActiveTheme implements DeviceDetectionInterface
16{ 16{
17 protected $tokenStorage; 17 protected $tokenStorage;
18 protected $defaultTheme; 18 protected $defaultTheme;
19 protected $themes;
19 20
20 /** 21 /**
21 * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user 22 * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user
22 * @param string $defaultTheme Default theme when user isn't logged in 23 * @param string $defaultTheme Default theme when user isn't logged in
24 * @param array $themes Themes come from the LiipThemeBundle (liip_theme.themes)
23 */ 25 */
24 public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme) 26 public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme, $themes)
25 { 27 {
26 $this->tokenStorage = $tokenStorage; 28 $this->tokenStorage = $tokenStorage;
27 $this->defaultTheme = $defaultTheme; 29 $this->defaultTheme = $defaultTheme;
30 $this->themes = $themes;
28 } 31 }
29 32
30 public function setUserAgent($userAgent) 33 public function setUserAgent($userAgent)
@@ -60,6 +63,10 @@ class DetectActiveTheme implements DeviceDetectionInterface
60 return $this->defaultTheme; 63 return $this->defaultTheme;
61 } 64 }
62 65
66 if (!in_array($config->getTheme(), $this->themes)) {
67 return $this->defaultTheme;
68 }
69
63 return $config->getTheme(); 70 return $config->getTheme();
64 } 71 }
65} 72}