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