-
Notifications
You must be signed in to change notification settings - Fork 1
/
cookiebanner.php
36 lines (29 loc) · 878 Bytes
/
cookiebanner.php
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
<?php
namespace Plugins\CookieBanner;
use \Typemill\Plugin;
class CookieBanner extends Plugin
{
protected $settings;
public static function getSubscribedEvents()
{
return array(
'onSettingsLoaded' => 'onSettingsLoaded',
'onTwigLoaded' => 'onTwigLoaded'
);
}
public function onSettingsLoaded($settings)
{
$this->settings = $settings->getData();
}
public function onTwigLoaded()
{
/* add external CSS and JavaScript */
$this->addCSS('/cookiebanner/public/cookiebanner-assets.css');
/* get Twig Instance and add the cookiebanner template-folder to the path */
$twig = $this->getTwig();
$loader = $twig->getLoader();
$loader->addPath(__DIR__ . '/templates');
/* fetch the template, render it with twig and add it sas inline-javascript */
$this->addInlineJS($twig->fetch('/cookiebanner.twig', $this->settings));
}
}