Completed
Push — master ( ab2f9c...c343b6 )
by David
01:57
created

TemplateExtension::onPreDispatch()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
/**
3
 * Tag Manager
4
 * Copyright (c) Webmatch GmbH
5
 *
6
 * This program is free software: you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation, either version 3 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 */
16
17
namespace WbmTagManager\Subscriber\Backend;
18
19
use Enlight\Event\SubscriberInterface;
20
21
/**
22
 * Class TemplateExtension
23
 */
24
class TemplateExtension implements SubscriberInterface
25
{
26
    /**
27
     * @var \Enlight_Template_Manager
28
     */
29
    private $template;
30
31
    /**
32
     * @var string
33
     */
34
    private $pluginDir;
35
36
    /**
37
     * @param \Enlight_Template_Manager $template
38
     * @param string                    $pluginDir
39
     */
40
    public function __construct(
41
        \Enlight_Template_Manager $template,
42
        $pluginDir
43
    ) {
44
        $this->template = $template;
45
        $this->pluginDir = $pluginDir;
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    public static function getSubscribedEvents()
52
    {
53
        return [
54
            'Enlight_Controller_Action_PreDispatch' => 'onPreDispatch',
55
        ];
56
    }
57
58
    public function onPreDispatch()
59
    {
60
        $this->template->addTemplateDir(
61
            $this->pluginDir . '/Resources/views/'
62
        );
63
    }
64
}
65