Completed
Pull Request — master (#562)
by Oliver
04:48 queued 02:59
created

Module::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 72
    public function init(ModuleManagerInterface $manager)
32
    {
33
        // Initialize the console
34
        $manager
35 72
            ->getEventManager()
36 72
            ->getSharedManager()
37 72
            ->attach(
38 72
                'doctrine',
39 72
                'loadCli.post',
40 72
                function (EventInterface $event) {
41
                    $event
42
                        ->getParam('ServiceManager')
43
                        ->get(CliConfigurator::class)
44
                        ->configure($event->getTarget())
45
                        ;
46 72
                },
47 72
                1
48
            );
49 72
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function onBootstrap(EventInterface $event)
55
    {
56
        /* @var $application \Zend\Mvc\Application */
57
        $application = $event->getTarget();
58
59
        /* @var $container ContainerInterface */
60
        $container = $application->getServiceManager();
61
62
        $events = $application->getEventManager();
63
64
        // Initialize logger collector once the profiler is initialized itself
65
        $events->attach(
66
            'profiler_init',
67
            function () use ($container) {
68
                $container->get('doctrine.sql_logger_collector.orm_default');
69
            }
70
        );
71
    }
72
73
    /**
74
     * {@inheritDoc}
75
     */
76 72
    public function getConfig()
77
    {
78 72
        return include __DIR__ . '/../../config/module.config.php';
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84 72
    public function getControllerConfig()
85
    {
86 72
        return include __DIR__ . '/../../config/controllers.config.php';
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92 72
    public function getModuleDependencies()
93
    {
94 72
        return ['DoctrineModule'];
95
    }
96
}
97