blob: 2a943bb7d2400e3489ea49438ab97759a3929c16 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
<?php
namespace Wallabag\CoreBundle\Helper;
use Liip\ThemeBundle\Helper\DeviceDetectionInterface;
use Symfony\Component\Security\Core\SecurityContextInterface;
use Wallabag\CoreBundle\Entity\User;
class DetectActiveTheme implements DeviceDetectionInterface
{
protected $securityContext;
public function __construct(SecurityContextInterface $securityContext)
{
$this->securityContext = $securityContext;
}
public function setUserAgent($userAgent)
{
}
/**
* This should return the active theme for the logged in user.
* No active theme for:
* - anonymous user
* - user without a config (shouldn't happen..)
*
* @return string
*/
public function getType()
{
$user = $this->securityContext->getToken()->getUser();
// anon user don't deserve a theme
if (!$user instanceof User) {
return false;
}
$config = $user->getConfig();
if (!$config) {
return false;
}
return $config->getTheme();
}
}
|