Completed
Push — release/1.1.8 ( d0ff7a )
by Tom
08:38 queued 01:13
created

Module::init()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 32
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
dl 0
loc 32
rs 8.8571
c 2
b 0
f 0
cc 2
eloc 21
nc 2
nop 1
1
<?php
2
3
namespace DoctrineORMModule;
4
5
use Interop\Container\ContainerInterface;
6
use Zend\EventManager\EventInterface;
7
use Zend\ModuleManager\Feature\ControllerProviderInterface;
8
use Zend\ModuleManager\Feature\ConfigProviderInterface;
9
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
10
use Zend\ModuleManager\ModuleManagerInterface;
11
use DoctrineORMModule\CliConfigurator;
12
use ZendDeveloperTools\ProfilerEvent;
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
    ControllerProviderInterface,
24
    ConfigProviderInterface,
25
    DependencyIndicatorInterface
26
{
27
    /**
28
     * {@inheritDoc}
29
     */
30
    public function init(ModuleManagerInterface $manager)
31
    {
32
        // Initialize the console
33
        $manager
34
            ->getEventManager()
35
            ->getSharedManager()
36
            ->attach(
37
                'doctrine',
38
                'loadCli.post',
39
                function (EventInterface $event) {
40
                    $event
41
                        ->getParam('ServiceManager')
42
                        ->get(CliConfigurator::class)
43
                        ->configure($event->getTarget())
44
                        ;
45
                },
46
                1
47
            );
48
49
        // Initialize logger collector in ZendDeveloperTools
50
        if (class_exists(ProfilerEvent::class)) {
51
            $manager
52
                ->getEventManager()
53
                ->attach(
54
                    ProfilerEvent::EVENT_PROFILER_INIT,
55
                    function ($event) {
56
                        $container = $event->getTarget()->getParam('ServiceManager');
57
                        $container->get('doctrine.sql_logger_collector.orm_default');
58
                    }
59
                );
60
        }
61
    }
62
63
    /**
64
     * {@inheritDoc}
65
     */
66
    public function getConfig()
67
    {
68
        return include __DIR__ . '/../../config/module.config.php';
69
    }
70
71
    /**
72
     * {@inheritDoc}
73
     */
74
    public function getControllerConfig()
75
    {
76
        return include __DIR__ . '/../../config/controllers.config.php';
77
    }
78
79
    /**
80
     * {@inheritDoc}
81
     */
82
    public function getModuleDependencies()
83
    {
84
        return ['DoctrineModule'];
85
    }
86
}
87