TemplateRegistration   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onPreDispatch() 0 3 1
A __construct() 0 7 1
A getSubscribedEvents() 0 4 1
1
<?php
2
3
namespace DnViewSnapshots\Subscriber;
4
5
use Enlight\Event\SubscriberInterface;
0 ignored issues
show
Bug introduced by
The type Enlight\Event\SubscriberInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
7
/**
8
 * Class TemplateRegistration
9
 * @package DnViewSnapshots\Subscriber
10
 */
11
class TemplateRegistration implements SubscriberInterface
12
{
13
    /**
14
     * @var string
15
     */
16
    private $pluginDirectory;
17
18
    /**
19
     * @var \Enlight_Template_Manager
0 ignored issues
show
Bug introduced by
The type Enlight_Template_Manager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
20
     */
21
    private $templateManager;
22
23
    /**
24
     * TemplateRegistration constructor.
25
     * @param $pluginDirectory
26
     * @param \Enlight_Template_Manager $templateManager
27
     */
28
    public function __construct(
29
        $pluginDirectory,
30
        \Enlight_Template_Manager $templateManager
31
    )
32
    {
33
        $this->pluginDirectory = $pluginDirectory;
34
        $this->templateManager = $templateManager;
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40
    public static function getSubscribedEvents()
41
    {
42
        return [
43
            'Enlight_Controller_Action_PreDispatch' => 'onPreDispatch',
44
        ];
45
    }
46
47
    public function onPreDispatch()
48
    {
49
        $this->templateManager->addTemplateDir($this->pluginDirectory . '/Resources/views');
50
    }
51
}