1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of the Superdesk Web Publisher Web Renderer Bundle. |
5
|
|
|
* |
6
|
|
|
* Copyright 2015 Sourcefabric z.u. and contributors. |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please see the |
9
|
|
|
* AUTHORS and LICENSE files distributed with this source code. |
10
|
|
|
* |
11
|
|
|
* @copyright 2015 Sourcefabric z.ú. |
12
|
|
|
* @license http://www.superdesk.org/license |
13
|
|
|
*/ |
14
|
|
|
namespace SWP\Bundle\WebRendererBundle\EventListener; |
15
|
|
|
|
16
|
|
|
use Sylius\Bundle\ThemeBundle\Context\ThemeContextInterface; |
17
|
|
|
use Sylius\Bundle\ThemeBundle\Repository\ThemeRepositoryInterface; |
18
|
|
|
use Symfony\Component\HttpKernel\Event\GetResponseEvent; |
19
|
|
|
use Symfony\Component\HttpKernel\HttpKernelInterface; |
20
|
|
|
|
21
|
|
|
class ActiveThemeListener |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @var ThemeRepositoryInterface |
25
|
|
|
*/ |
26
|
|
|
private $themeRepository; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* @var ThemeContextInterface |
30
|
|
|
*/ |
31
|
|
|
private $themeContext; |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* @param ThemeRepositoryInterface $themeRepository |
35
|
|
|
* @param ThemeContextInterface $themeContext |
36
|
|
|
*/ |
37
|
|
|
public function __construct(ThemeRepositoryInterface $themeRepository, ThemeContextInterface $themeContext) |
38
|
|
|
{ |
39
|
|
|
$this->themeRepository = $themeRepository; |
40
|
|
|
$this->themeContext = $themeContext; |
41
|
|
|
} |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @param GetResponseEvent $event |
45
|
|
|
*/ |
46
|
|
|
public function onKernelRequest(GetResponseEvent $event) |
47
|
|
|
{ |
48
|
|
|
if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) { |
49
|
|
|
// don't do anything if it's not the master request |
50
|
|
|
return; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
$this->themeContext->setTheme( |
54
|
|
|
// for now just hardcode default theme |
55
|
|
|
$this->themeRepository->findOneByName('swp/default-theme') |
56
|
|
|
); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|