diff options
author | Jeremy <jeremy.benoist@gmail.com> | 2015-02-23 22:55:06 +0100 |
---|---|---|
committer | Jeremy <jeremy.benoist@gmail.com> | 2015-03-01 10:49:16 +0100 |
commit | 32da2a70ef278bd42f66eb82c3fbf1905a417b87 (patch) | |
tree | 587ef3bae1f4881047eb1ceb0c005e7a8287bb71 /src/Wallabag/CoreBundle/Helper | |
parent | fca3c757233940cbe4c431e3e05fe74893225fe0 (diff) | |
download | wallabag-32da2a70ef278bd42f66eb82c3fbf1905a417b87.tar.gz wallabag-32da2a70ef278bd42f66eb82c3fbf1905a417b87.tar.zst wallabag-32da2a70ef278bd42f66eb82c3fbf1905a417b87.zip |
Add LiipThemeBundle
Re-defined the config / user relation to be OneToOne bidirectionnal.
ConfigType is now a service so I can inject the list of available themes that are also used by LiipThemeBundle
Force sqlite for test
In case of people use a different driver in parameter.yml (yes I do :))
Diffstat (limited to 'src/Wallabag/CoreBundle/Helper')
-rw-r--r-- | src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php new file mode 100644 index 00000000..2a943bb7 --- /dev/null +++ b/src/Wallabag/CoreBundle/Helper/DetectActiveTheme.php | |||
@@ -0,0 +1,47 @@ | |||
1 | <?php | ||
2 | |||
3 | namespace Wallabag\CoreBundle\Helper; | ||
4 | |||
5 | use Liip\ThemeBundle\Helper\DeviceDetectionInterface; | ||
6 | use Symfony\Component\Security\Core\SecurityContextInterface; | ||
7 | use Wallabag\CoreBundle\Entity\User; | ||
8 | |||
9 | class DetectActiveTheme implements DeviceDetectionInterface | ||
10 | { | ||
11 | protected $securityContext; | ||
12 | |||
13 | public function __construct(SecurityContextInterface $securityContext) | ||
14 | { | ||
15 | $this->securityContext = $securityContext; | ||
16 | } | ||
17 | |||
18 | public function setUserAgent($userAgent) | ||
19 | { | ||
20 | } | ||
21 | |||
22 | /** | ||
23 | * This should return the active theme for the logged in user. | ||
24 | * No active theme for: | ||
25 | * - anonymous user | ||
26 | * - user without a config (shouldn't happen..) | ||
27 | * | ||
28 | * @return string | ||
29 | */ | ||
30 | public function getType() | ||
31 | { | ||
32 | $user = $this->securityContext->getToken()->getUser(); | ||
33 | |||
34 | // anon user don't deserve a theme | ||
35 | if (!$user instanceof User) { | ||
36 | return false; | ||
37 | } | ||
38 | |||
39 | $config = $user->getConfig(); | ||
40 | |||
41 | if (!$config) { | ||
42 | return false; | ||
43 | } | ||
44 | |||
45 | return $config->getTheme(); | ||
46 | } | ||
47 | } | ||