|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace allejo\stakx\EventSubscriber; |
|
4
|
|
|
|
|
5
|
|
|
use allejo\stakx\Configuration; |
|
6
|
|
|
use allejo\stakx\Event\PageViewsCompleted; |
|
7
|
|
|
use allejo\stakx\Manager\CollectionManager; |
|
8
|
|
|
use allejo\stakx\Manager\DataManager; |
|
9
|
|
|
use allejo\stakx\Manager\MenuManager; |
|
10
|
|
|
use allejo\stakx\Manager\PageManager; |
|
11
|
|
|
use allejo\stakx\Templating\TemplateBridgeInterface; |
|
12
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
|
13
|
|
|
use Symfony\Component\EventDispatcher\EventSubscriberInterface; |
|
14
|
|
|
|
|
15
|
|
|
class PageViewsCompletedSubscriber implements EventSubscriberInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* @var ContainerInterface |
|
19
|
|
|
*/ |
|
20
|
|
|
private $container; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct(ContainerInterface $container) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->container = $container; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* {@inheritdoc} |
|
29
|
|
|
*/ |
|
30
|
|
|
public static function getSubscribedEvents() |
|
31
|
|
|
{ |
|
32
|
|
|
return [ |
|
33
|
|
|
PageViewsCompleted::NAME => 'onPageViewsCompleted' |
|
34
|
|
|
]; |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function onPageViewsCompleted() |
|
38
|
|
|
{ |
|
39
|
|
|
/** @var TemplateBridgeInterface $twig */ |
|
40
|
|
|
$twig = $this->container->get('templating'); |
|
41
|
|
|
$twig->setGlobalVariable('site', $this->container->get(Configuration::class)->getconfiguration()); |
|
42
|
|
|
|
|
43
|
|
|
$dataItems = []; |
|
44
|
|
|
if ($this->container->has(DataManager::class)) { |
|
45
|
|
|
$dataItems = $this->container->get(DataManager::class)->getJailedDataItems(); |
|
46
|
|
|
} |
|
47
|
|
|
$twig->setGlobalVariable('data', $dataItems); |
|
48
|
|
|
|
|
49
|
|
|
$collectionItems = []; |
|
50
|
|
|
if ($this->container->has(CollectionManager::class)) { |
|
51
|
|
|
$collectionItems = $this->container->get(CollectionManager::class)->getJailedCollections(); |
|
52
|
|
|
} |
|
53
|
|
|
$twig->setGlobalVariable('collections', $collectionItems); |
|
54
|
|
|
|
|
55
|
|
|
$twig->setGlobalVariable('menu', $this->container->get(MenuManager::class)->getSiteMenu()); |
|
56
|
|
|
$twig->setGlobalVariable('pages', $this->container->get(PageManager::class)->getJailedStaticPageViews()); |
|
57
|
|
|
} |
|
58
|
|
|
} |