Completed
Pull Request — master (#560)
by Tom
09:01
created

Module::getModuleDependencies()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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
    public function init(ModuleManagerInterface $manager)
32
    {
33
        $events = $manager->getEventManager();
34
        $serviceManager = $manager->getEvent()->getParam('ServiceManager');
0 ignored issues
show
Bug introduced by
The method getEvent() does not exist on Zend\ModuleManager\ModuleManagerInterface. Did you maybe mean getEventManager()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
Unused Code introduced by
$serviceManager is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
35
36
        $events->getSharedManager()->attach('doctrine', 'loadCli.post', [$this, 'initializeConsole'], 1);
37
    }
38
39
    /**
40
     * Initialize the Doctrine console
41
     *
42
     * @param EventInterface
43
     */
44
    public function initializeConsole(EventInterface $event)
45
    {
46
        $container = $event->getParam('ServiceManager');
47
        $cliConfigurator = $container->get(CliConfigurator::class);
48
        $cliConfigurator->configure($event->getTarget());
49
    }
50
51
    /**
52
     * {@inheritDoc}
53
     */
54
    public function onBootstrap(EventInterface $event)
55 72
    {
56
        /* @var $application \Zend\Mvc\Application */
57 72
        $application = $event->getTarget();
58
59
        /* @var $container ContainerInterface */
60
        $container = $application->getServiceManager();
61
62
        $events = $application->getEventManager();
63 72
64
        // Initialize logger collector once the profiler is initialized itself
65 72
        $events->attach(
66
            'profiler_init',
67
            function () use ($container) {
68
                $container->get('doctrine.sql_logger_collector.orm_default');
69
            }
70
        );
71 72
    }
72
73 72
    /**
74
     * {@inheritDoc}
75
     */
76
    public function getConfig()
77
    {
78
        return include __DIR__ . '/../../config/module.config.php';
79
    }
80
81
    /**
82
     * {@inheritDoc}
83
     */
84
    public function getControllerConfig()
85
    {
86
        return include __DIR__ . '/../../config/controllers.config.php';
87
    }
88
89
    /**
90
     * {@inheritDoc}
91
     */
92
    public function getModuleDependencies()
93
    {
94
        return ['DoctrineModule'];
95
    }
96
}
97