]> git.immae.eu Git - github/wallabag/wallabag.git/blobdiff - src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php
Removed old, not so maintained and buggy baggy theme
[github/wallabag/wallabag.git] / src / Wallabag / CoreBundle / Helper / DetectActiveTheme.php
index 9f90ee3e21d01e38fa77b6b92c36d321bd2346b2..f1d5fdea6e98635ea67a888d4597be9898cf0e52 100644 (file)
@@ -16,15 +16,18 @@ class DetectActiveTheme implements DeviceDetectionInterface
 {
     protected $tokenStorage;
     protected $defaultTheme;
+    protected $themes;
 
     /**
      * @param TokenStorageInterface $tokenStorage Needed to retrieve the current user
      * @param string                $defaultTheme Default theme when user isn't logged in
+     * @param array $themes    Themes come from the LiipThemeBundle (liip_theme.themes)
      */
-    public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme)
+    public function __construct(TokenStorageInterface $tokenStorage, $defaultTheme, $themes)
     {
         $this->tokenStorage = $tokenStorage;
         $this->defaultTheme = $defaultTheme;
+        $this->themes = $themes;
     }
 
     public function setUserAgent($userAgent)
@@ -60,6 +63,10 @@ class DetectActiveTheme implements DeviceDetectionInterface
             return $this->defaultTheme;
         }
 
+        if (!in_array($config->getTheme(), $this->themes)) {
+            return $this->defaultTheme;
+        }
+
         return $config->getTheme();
     }
 }