Completed
Pull Request — develop (#603)
by Tom
03:54 queued 01:08
created

Module::getModuleDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

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
nc 1
nop 0
crap 1
1
<?php
2
3
namespace DoctrineORMModule;
4
5
use DoctrineORMModule\CliConfigurator;
6
use Interop\Container\ContainerInterface;
7
use Laminas\EventManager\EventInterface;
8
use Laminas\ModuleManager\Feature\ControllerProviderInterface;
9
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
10
use Laminas\ModuleManager\Feature\DependencyIndicatorInterface;
11
use Laminas\ModuleManager\ModuleManagerInterface;
12
use Laminas\DeveloperTools\ProfilerEvent;
13
14
/**
15
 * Base module for Doctrine ORM.
16
 */
17
class Module implements
18
    ControllerProviderInterface,
19
    ConfigProviderInterface,
20
    DependencyIndicatorInterface
21
{
22
    /**
23
     * {@inheritDoc}
24
     */
25 72
    public function init(ModuleManagerInterface $manager)
26
    {
27
        // Initialize the console
28
        $manager
29 72
            ->getEventManager()
30 72
            ->getSharedManager()
31 72
            ->attach(
32 72
                'doctrine',
33 72
                'loadCli.post',
34
                function (EventInterface $event) {
35
                    $event
36
                        ->getParam('ServiceManager')
37
                        ->get(CliConfigurator::class)
38
                        ->configure($event->getTarget())
39
                        ;
40 72
                },
41 72
                1
42
            );
43
44
        // Initialize logger collector in DeveloperTools
45 72
        if (class_exists(ProfilerEvent::class)) {
46
            $manager
47 72
                ->getEventManager()
48 72
                ->attach(
49 72
                    ProfilerEvent::EVENT_PROFILER_INIT,
50
                    function ($event) {
51
                        $container = $event->getTarget()->getParam('ServiceManager');
52
                        $container->get('doctrine.sql_logger_collector.orm_default');
53 72
                    }
54
                );
55
        }
56 72
    }
57
58
    /**
59
     * {@inheritDoc}
60
     */
61 72
    public function getConfig()
62
    {
63 72
        return include __DIR__ . '/../../config/module.config.php';
64
    }
65
66
    /**
67
     * {@inheritDoc}
68
     */
69 72
    public function getControllerConfig()
70
    {
71 72
        return include __DIR__ . '/../../config/controllers.config.php';
72
    }
73
74
    /**
75
     * {@inheritDoc}
76
     */
77 72
    public function getModuleDependencies()
78
    {
79 72
        return ['DoctrineModule'];
80
    }
81
}
82