Completed
Pull Request — master (#615)
by Filippo
14:02 queued 03:29
created

Module::getConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 10
nc 1
nop 0
crap 1
1
<?php
2
3
namespace DoctrineModule;
4
5
use Doctrine\Common\Annotations\AnnotationRegistry;
6
use Zend\ModuleManager\Feature\InitProviderInterface;
7
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
8
use Zend\ModuleManager\Feature\ConfigProviderInterface;
9
use Zend\ModuleManager\ModuleManagerInterface;
10
use Zend\EventManager\EventInterface;
11
use Zend\Console\Adapter\AdapterInterface as Console;
12
13
use Symfony\Component\Console\Input\StringInput;
14
use DoctrineModule\Component\Console\Output\PropertyOutput;
15
16
/**
17
 * Base module for integration of Doctrine projects with ZF2 applications
18
 *
19
 * @license MIT
20
 * @link    http://www.doctrine-project.org/
21
 * @since   0.1.0
22
 * @author  Kyle Spraggs <[email protected]>
23
 * @author  Marco Pivetta <[email protected]>
24
 */
25
class Module implements ConfigProviderInterface, InitProviderInterface, BootstrapListenerInterface
26
{
27
    /**
28
     * @var \Zend\ServiceManager\ServiceLocatorInterface
29
     */
30
    private $serviceManager;
31
32
    /**
33
     * {@inheritDoc}
34
     */
35 30
    public function init(ModuleManagerInterface $moduleManager)
36
    {
37 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 autoloading should be deferred to the globally registered autoloader by then. For now, use @example AnnotationRegistry::registerLoader('class_exists')

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...
38 30
            function ($className) {
39
                return class_exists($className);
40 30
            }
41
        );
42 30
    }
43
44
    /**
45
     * {@inheritDoc}
46
     */
47 1
    public function onBootstrap(EventInterface $event)
48
    {
49 1
        $this->serviceManager = $event->getTarget()->getServiceManager();
50 1
    }
51
52
    /**
53
     * {@inheritDoc}
54
     */
55 31
    public function getConfig()
56
    {
57 31
        $provider = new ConfigProvider();
58
        return [
59 31
            'doctrine' => $provider->getDoctrineConfig(),
60 31
            'doctrine_factories' => $provider->getDoctrineFactoryConfig(),
61 31
            'service_manager' => $provider->getDependencyConfig(),
62 31
            'controllers' => $provider->getControllerConfig(),
63 31
            'route_manager' => $provider->getRouteManagerConfig(),
64 31
            'console' => $provider->getConsoleConfig(),
65 31
            'validators' => $provider->getValidatorConfig(),
66
        ];
67
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72 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...
73
    {
74
        /* @var $cli \Symfony\Component\Console\Application */
75 1
        $cli    = $this->serviceManager->get('doctrine.cli');
76 1
        $output = new PropertyOutput();
77
78 1
        $cli->run(new StringInput('list'), $output);
79
80 1
        return $output->getMessage();
81
    }
82
}
83