Completed
Push — master ( 20b2e7...221c15 )
by Tom
16:49 queued 06:52
created

Module   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 31.58%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 5
c 4
b 0
f 0
lcom 0
cbo 5
dl 0
loc 75
ccs 6
cts 19
cp 0.3158
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A onBootstrap() 0 18 1
A getConfig() 0 4 1
A getControllerConfig() 0 4 1
A getModuleDependencies() 0 4 1
A init() 0 19 1
1
<?php
2
3
namespace DoctrineORMModule;
4
5
use Interop\Container\ContainerInterface;
6
use Zend\EventManager\EventInterface;
7
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
8
use Zend\ModuleManager\Feature\ControllerProviderInterface;
9
use Zend\ModuleManager\Feature\ConfigProviderInterface;
10
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
11
use Zend\ModuleManager\ModuleManagerInterface;
12
use DoctrineORMModule\CliConfigurator;
13
14
/**
15
 * Base module for Doctrine ORM.
16
 *
17
 * @license MIT
18
 * @link    www.doctrine-project.org
19
 * @author  Kyle Spraggs <[email protected]>
20
 * @author  Marco Pivetta <[email protected]>
21
 */
22
class Module implements
23
    BootstrapListenerInterface,
24
    ControllerProviderInterface,
25
    ConfigProviderInterface,
26
    DependencyIndicatorInterface
27
{
28
    /**
29
     * {@inheritDoc}
30
     */
31
    public function init(ModuleManagerInterface $manager)
32
    {
33
        // Initialize the console
34
        $manager
35
            ->getEventManager()
36
            ->getSharedManager()
37
            ->attach(
38
                'doctrine',
39
                'loadCli.post',
40
                function (EventInterface $event) {
41
                    $event
42
                        ->getParam('ServiceManager')
43
                        ->get(CliConfigurator::class)
44
                        ->configure($event->getTarget())
45
                        ;
46
                },
47
                1
48
            );
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function onBootstrap(EventInterface $event)
55 72
    {
56
        /* @var $application \Zend\Mvc\Application */
57 72
        $application = $event->getTarget();
58
59
        /* @var $container ContainerInterface */
60
        $container = $application->getServiceManager();
61
62
        $events = $application->getEventManager();
63 72
64
        // Initialize logger collector once the profiler is initialized itself
65 72
        $events->attach(
66
            'profiler_init',
67
            function () use ($container) {
68
                $container->get('doctrine.sql_logger_collector.orm_default');
69
            }
70
        );
71 72
    }
72
73 72
    /**
74
     * {@inheritDoc}
75
     */
76
    public function getConfig()
77
    {
78
        return include __DIR__ . '/../../config/module.config.php';
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public function getControllerConfig()
85
    {
86
        return include __DIR__ . '/../../config/controllers.config.php';
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92
    public function getModuleDependencies()
93
    {
94
        return ['DoctrineModule'];
95
    }
96
}
97