Completed
Pull Request — develop (#607)
by Tom
03:12 queued 01:40
created

Module::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
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
    public function init(ModuleManagerInterface $manager)
27
    {
28
        // Initialize the console
29
        $manager
30
            ->getEventManager()
31
            ->getSharedManager()
32
            ->attach(
33
                'doctrine',
34
                'loadCli.post',
35
                static function (EventInterface $event) : void {
36
                    $event
37
                        ->getParam('ServiceManager')
38
                        ->get(CliConfigurator::class)
39
                        ->configure($event->getTarget());
40
                },
41
                1
42
            );
43
44
        // Initialize logger collector in DeveloperTools
45
        if (! class_exists(ProfilerEvent::class)) {
46
            return;
47
        }
48
49
        $manager
50
            ->getEventManager()
51
            ->attach(
52
                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
                }
57
            );
58
    }
59
60
    /**
61
     * {@inheritDoc}
62
     */
63
    public function getConfig()
64
    {
65
        return include __DIR__ . '/../../config/module.config.php';
66
    }
67
68
    /**
69
     * {@inheritDoc}
70
     */
71
    public function getControllerConfig()
72
    {
73
        return include __DIR__ . '/../../config/controllers.config.php';
74
    }
75
76
    /**
77
     * {@inheritDoc}
78
     */
79
    public function getModuleDependencies()
80
    {
81
        return ['DoctrineModule'];
82
    }
83
}
84