Completed
Push — master ( 960666...619cc6 )
by Tom
14s
created

Module::getConsoleUsage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
crap 1
1
<?php
2
/*
3
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 *
15
 * This software consists of voluntary contributions made by many individuals
16
 * and is licensed under the MIT license. For more information, see
17
 * <http://www.doctrine-project.org>.
18
 */
19
20
namespace DoctrineModule;
21
22
use Doctrine\Common\Annotations\AnnotationRegistry;
23
use Zend\ModuleManager\Feature\InitProviderInterface;
24
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
25
use Zend\ModuleManager\Feature\ConfigProviderInterface;
26
use Zend\ModuleManager\ModuleManagerInterface;
27
use Zend\EventManager\EventInterface;
28
use Zend\Console\Adapter\AdapterInterface as Console;
29
30
use Symfony\Component\Console\Input\StringInput;
31
use DoctrineModule\Component\Console\Output\PropertyOutput;
32
33
/**
34
 * Base module for integration of Doctrine projects with ZF2 applications
35
 *
36
 * @license MIT
37
 * @link    http://www.doctrine-project.org/
38
 * @since   0.1.0
39
 * @author  Kyle Spraggs <[email protected]>
40
 * @author  Marco Pivetta <[email protected]>
41
 */
42
class Module implements ConfigProviderInterface, InitProviderInterface, BootstrapListenerInterface
43
{
44
    /**
45
     * @var \Zend\ServiceManager\ServiceLocatorInterface
46
     */
47
    private $serviceManager;
48
49
    /**
50
     * {@inheritDoc}
51
     */
52 30
    public function init(ModuleManagerInterface $moduleManager)
53
    {
54 30
        AnnotationRegistry::registerLoader(
55
            function ($className) {
56
                return class_exists($className);
57
            }
58 30
        );
59 30
    }
60
61
    /**
62
     * {@inheritDoc}
63
     */
64 1
    public function onBootstrap(EventInterface $event)
65
    {
66 1
        $this->serviceManager = $event->getTarget()->getServiceManager();
67 1
    }
68
69
    /**
70
     * {@inheritDoc}
71
     */
72 31
    public function getConfig()
73
    {
74 31
        $provider = new ConfigProvider();
75
        return [
76 31
            'doctrine' => $provider->getDoctrineConfig(),
77 31
            'doctrine_factories' => $provider->getDoctrineFactoryConfig(),
78 31
            'service_manager' => $provider->getDependencyConfig(),
79 31
            'controllers' => $provider->getControllerConfig(),
80 31
            'route_manager' => $provider->getRouteManagerConfig(),
81 31
            'console' => $provider->getConsoleConfig(),
82 31
            'validators' => $provider->getValidatorConfig(),
83 31
        ];
84
    }
85
86
    /**
87
     * {@inheritDoc}
88
     */
89 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...
90
    {
91
        /* @var $cli \Symfony\Component\Console\Application */
92 1
        $cli    = $this->serviceManager->get('doctrine.cli');
93 1
        $output = new PropertyOutput();
94
95 1
        $cli->run(new StringInput('list'), $output);
96
97 1
        return $output->getMessage();
98
    }
99
}
100