Completed
Pull Request — master (#542)
by Nicolas
03:15
created

Module::onBootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 1.0122

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 21
ccs 10
cts 13
cp 0.7692
rs 9.3142
cc 1
eloc 10
nc 1
nop 1
crap 1.0122
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace DoctrineORMModule;
21
22
use DoctrineORMModule\Listener\PostCliLoadListener;
23
use Interop\Container\ContainerInterface;
24
use Zend\EventManager\EventInterface;
25
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
26
use Zend\ModuleManager\Feature\ControllerProviderInterface;
27
use Zend\ModuleManager\Feature\ConfigProviderInterface;
28
use Zend\ModuleManager\Feature\DependencyIndicatorInterface;
29
30
/**
31
 * Base module for Doctrine ORM.
32
 *
33
 * @license MIT
34
 * @link    www.doctrine-project.org
35
 * @author  Kyle Spraggs <[email protected]>
36
 * @author  Marco Pivetta <[email protected]>
37
 */
38
class Module implements
39
    BootstrapListenerInterface,
40
    ControllerProviderInterface,
41
    ConfigProviderInterface,
42
    DependencyIndicatorInterface
43
{
44
    /**
45
     * {@inheritDoc}
46
     */
47 16
    public function onBootstrap(EventInterface $event)
48
    {
49
        /* @var $application \Zend\Mvc\Application */
50 16
        $application = $event->getTarget();
51
        /* @var $container ContainerInterface */
52 16
        $container = $application->getServiceManager();
53
54 16
        $events = $application->getEventManager();
55
56
        // Initialize logger collector once the profiler is initialized itself
57 16
        $events->attach(
58 16
            'profiler_init',
59
            function () use ($container) {
60
                $container->get('doctrine.sql_logger_collector.orm_default');
61
            }
62 16
        );
63
64
        /* @var $postCliLoadListener PostCliLoadListener */
65 16
        $postCliLoadListener = $container->get(PostCliLoadListener::class);
66 16
        $postCliLoadListener->attach($events);
67 16
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72 72
    public function getConfig()
73
    {
74 72
        return include __DIR__ . '/../../config/module.config.php';
75
    }
76
77
    /**
78
     * {@inheritDoc}
79
     */
80 72
    public function getControllerConfig()
81
    {
82 72
        return include __DIR__ . '/../../config/controllers.config.php';
83
    }
84
85
    /**
86
     * {@inheritDoc}
87
     */
88 72
    public function getModuleDependencies()
89
    {
90 72
        return ['DoctrineModule'];
91
    }
92
}
93