1 | <?php |
||
10 | class CookieConsentExtension extends \Twig_Extension |
||
11 | { |
||
12 | /** |
||
13 | * @var TranslatorInterface |
||
14 | */ |
||
15 | private $translator; |
||
16 | |||
17 | /** |
||
18 | * Configuration values and options passed to the template. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private $config = []; |
||
23 | |||
24 | /** |
||
25 | * List of label options and trans keys. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $labels = [ |
||
30 | 'message' => 'message', |
||
31 | 'dismiss' => 'dismiss', |
||
32 | 'learnMore' => 'learn_more', |
||
33 | ]; |
||
34 | |||
35 | /** |
||
36 | * @param TranslatorInterface $translator |
||
37 | */ |
||
38 | public function __construct(TranslatorInterface $translator) |
||
42 | |||
43 | /** |
||
44 | * {@inheritdoc} |
||
45 | */ |
||
46 | public function getFunctions() |
||
62 | |||
63 | /** |
||
64 | * {@inheritdoc} |
||
65 | */ |
||
66 | public function getName() |
||
70 | |||
71 | /** |
||
72 | * @param array $config |
||
73 | */ |
||
74 | public function setConfig(array $config) |
||
78 | |||
79 | /** |
||
80 | * Render cookie consent. |
||
81 | * |
||
82 | * @param \Twig_Environment $twigEnvironment |
||
83 | * |
||
84 | * @return string |
||
85 | */ |
||
86 | public function renderCookieConsent(\Twig_Environment $twigEnvironment) |
||
97 | |||
98 | /** |
||
99 | * Translate label options. |
||
100 | * |
||
101 | * @param array $options |
||
102 | * |
||
103 | * @return array |
||
104 | */ |
||
105 | private function appendLabelTranslations(array $options) |
||
113 | } |
||
114 |