Completed
Push — drop_php5.4 ( ed15b0 )
by Gianluca
16:11
created

Module::onBootstrap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
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
    public function init(ModuleManagerInterface $moduleManager)
53
    {
54
        AnnotationRegistry::registerLoader(
55
            function ($className) {
56
                return class_exists($className);
57
            }
58
        );
59
    }
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 1
    public function getConfig()
73
    {
74 1
        return include __DIR__ . '/../../config/module.config.php';
75
    }
76
77
    /**
78
     * {@inheritDoc}
79
     */
80 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...
81
    {
82
        /* @var $cli \Symfony\Component\Console\Application */
83 1
        $cli    = $this->serviceManager->get('doctrine.cli');
84 1
        $output = new PropertyOutput();
85
86 1
        $cli->run(new StringInput('list'), $output);
87
88 1
        return $output->getMessage();
89
    }
90
}
91