Completed
Push — master ( e0017c...6b1304 )
by Tom
14s queued 11s
created

Module::onBootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DoctrineModule;
6
7
use Doctrine\Common\Annotations\AnnotationRegistry;
8
use DoctrineModule\Component\Console\Output\PropertyOutput;
9
use Laminas\Console\Adapter\AdapterInterface as Console;
10
use Laminas\EventManager\EventInterface;
11
use Laminas\ModuleManager\Feature\BootstrapListenerInterface;
12
use Laminas\ModuleManager\Feature\ConfigProviderInterface;
13
use Laminas\ModuleManager\Feature\InitProviderInterface;
14
use Laminas\ModuleManager\ModuleManagerInterface;
15
use Laminas\ServiceManager\ServiceLocatorInterface;
16
use Symfony\Component\Console\Input\StringInput;
17
use function class_exists;
18
19
/**
20
 * Base module for integration of Doctrine projects with ZF2 applications
21
 *
22
 * @link    http://www.doctrine-project.org/
23
 */
24
class Module implements ConfigProviderInterface, InitProviderInterface, BootstrapListenerInterface
25
{
26
    /** @var ServiceLocatorInterface */
27
    private $serviceManager;
28
29
    /**
30
     * {@inheritDoc}
31
     */
32 30
    public function init(ModuleManagerInterface $moduleManager)
33
    {
34 30
        AnnotationRegistry::registerLoader(
0 ignored issues
show
Deprecated Code introduced by
The method Doctrine\Common\Annotati...istry::registerLoader() has been deprecated with message: This method is deprecated and will be removed in doctrine/annotations 2.0. Annotations will be autoloaded in 2.0.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
35
            static function ($className) {
36
                return class_exists($className);
37 30
            }
38
        );
39 30
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 1
    public function onBootstrap(EventInterface $event)
45
    {
46 1
        $this->serviceManager = $event->getTarget()->getServiceManager();
47 1
    }
48
49
    /**
50
     * {@inheritDoc}
51
     */
52 31
    public function getConfig()
53
    {
54 31
        $provider = new ConfigProvider();
55
56
        return [
57 31
            'doctrine' => $provider->getDoctrineConfig(),
58 31
            'doctrine_factories' => $provider->getDoctrineFactoryConfig(),
59 31
            'service_manager' => $provider->getDependencyConfig(),
60 31
            'controllers' => $provider->getControllerConfig(),
61 31
            'route_manager' => $provider->getRouteManagerConfig(),
62 31
            'console' => $provider->getConsoleConfig(),
63 31
            'validators' => $provider->getValidatorConfig(),
64
        ];
65
    }
66
67
    /**
68
     * {@inheritDoc}
69
     */
70 1
    public function getConsoleUsage(Console $console)
0 ignored issues
show
Unused Code introduced by
The parameter $console is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
71
    {
72 1
        $cli    = $this->serviceManager->get('doctrine.cli');
73 1
        $output = new PropertyOutput();
74
75 1
        $cli->run(new StringInput('list'), $output);
76
77 1
        return $output->getMessage();
78
    }
79
}
80