Module   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 6
dl 0
loc 86
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B init() 0 72 5
A getConfig() 0 4 1
1
<?php
2
/**
3
 * Webino (http://webino.sk)
4
 *
5
 * @link        https://github.com/webino/WebinoDraw for the canonical source repository
6
 * @copyright   Copyright (c) 2012-2017 Webino, s. r. o. (http://webino.sk)
7
 * @author      Peter Bačinský <[email protected]>
8
 * @license     BSD-3-Clause
9
 */
10
11
namespace WebinoDraw;
12
13
use WebinoDebug\Factory\DebuggerFactory;
14
use WebinoDebug\Service\Debugger;
15
use WebinoDraw\Debugger\DrawPanel;
16
use WebinoDraw\Draw\HelperPluginManager;
17
use WebinoDraw\Draw\LoopHelperPluginManager;
18
use WebinoDraw\Exception;
19
use WebinoDraw\Factory\HelperPluginManagerFactory;
20
use WebinoDraw\Factory\LoopHelperPluginManagerFactory;
21
use WebinoDraw\ModuleManager\Feature\WebinoDrawHelperProviderInterface;
22
use WebinoDraw\ModuleManager\Feature\WebinoDrawLoopHelperProviderInterface;
23
use Zend\Filter\FilterPluginManager;
24
use Zend\ModuleManager\Feature\ConfigProviderInterface;
25
use Zend\ModuleManager\ModuleEvent;
26
use Zend\ModuleManager\ModuleManager;
27
use Zend\ModuleManager\ModuleManagerInterface;
28
29
/**
30
 * Class Module
31
 */
32
class Module implements ConfigProviderInterface
33
{
34
    /**
35
     * @param ModuleManagerInterface $manager
36
     */
37
    public function init(ModuleManagerInterface $manager)
38
    {
39
        if (!($manager instanceof ModuleManager)) {
40
            throw new Exception\LogicException('Expected ' . ModuleManager::class);
41
        }
42
        
43
        $services = $manager->getEvent()->getParam('ServiceManager');
44
45
        // Register draw helper manager
46
        $services->setFactory(
47
            'WebinoDrawHelperManager',
48
            HelperPluginManagerFactory::class
49
        );
50
        $services->get('ServiceListener')->addServiceManager(
51
            'WebinoDrawHelperManager',
52
            'webino_draw_helpers',
53
            WebinoDrawHelperProviderInterface::class,
54
            'getWebinoDrawHelperConfig'
55
        );
56
57
        // Register draw loop helper manager
58
        $services->setFactory(
59
            'WebinoDrawLoopHelperManager',
60
            LoopHelperPluginManagerFactory::class
61
        );
62
        $services->get('ServiceListener')->addServiceManager(
63
            'WebinoDrawLoopHelperManager',
64
            'webino_draw_loop_helpers',
65
            WebinoDrawLoopHelperProviderInterface::class,
66
            'getWebinoDrawLoopHelperConfig'
67
        );
68
69
        // Register a debugger bar panel
70
        if (class_exists(DebuggerFactory::class) && $services->has(DebuggerFactory::SERVICE)) {
71
            $debugger = $services->get(DebuggerFactory::SERVICE);
72
            $debugger instanceof Debugger and $debugger->setBarPanel(new DrawPanel($manager), DrawPanel::ID);
0 ignored issues
show
Unused Code introduced by
The call to DrawPanel::__construct() has too many arguments starting with $manager.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
73
        }
74
75
        // Fixing some DI issues but deprecated
76
        $manager->getEventManager()->attach(
77
            ModuleEvent::EVENT_LOAD_MODULES_POST,
78
            function () use ($services) {
79
80
                // TODO: ZF2 issue
81
                // @link https://github.com/zendframework/zf2/issues/4573
82
                $services->get('FilterManager')->addPeeringServiceManager($services);
83
                $services->get('ViewHelperManager')->addPeeringServiceManager($services);
84
                $services->get('ValidatorManager')->addPeeringServiceManager($services);
85
86
                $instances = $services->get('Di')->instanceManager();
87
88
                // TODO: ZF2 DI issue
89
                // @link https://github.com/zendframework/zf2/issues/6290
90
                $instances->addSharedInstance(
91
                    $services->get('ViewHelperManager'),
92
                    HelperPluginManager::class
93
                );
94
                $instances->addSharedInstance(
95
                    $services->get('FilterManager'),
96
                    FilterPluginManager::class
97
                );
98
                $instances->addSharedInstance(
99
                    $services->get('WebinoDrawHelperManager'),
100
                    HelperPluginManager::class
101
                );
102
                $instances->addSharedInstance(
103
                    $services->get('WebinoDrawLoopHelperManager'),
104
                    LoopHelperPluginManager::class
105
                );
106
            }
107
        );
108
    }
109
110
    /**
111
     * @return array
112
     */
113
    public function getConfig()
114
    {
115
        return include __DIR__ . '/../../config/module.config.php';
116
    }
117
}
118