Module::getConfig()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace DoctrineRepoHelper;
4
5
use Doctrine\ORM\Tools\Console\ConsoleRunner;
6
use Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper;
7
use DoctrineRepoHelper\Command\GenerateDataFactoryCommand;
8
use DoctrineRepoHelper\Command\GenerateTraitCommand;
9
use DoctrineRepoHelper\Command\GenerateTypeScriptInterfaceCommand;
10
use Symfony\Component\Console\Application;
11
use Zend\EventManager\EventInterface;
12
use Zend\EventManager\EventManager;
13
use Zend\ModuleManager\ModuleManager;
14
15
/**
16
 * Class Module
17
 * @package DoctrineRepoHelper
18
 */
19
class Module
20
{
21
    /**
22
     * {@inheritDoc}
23
     */
24
    public function init(ModuleManager $e)
25
    {
26
        /** @var EventManager $events */
27
        $events = $e->getEventManager()->getSharedManager();
28
29
        $events->attach(
30
            'doctrine',
31
            'loadCli.post',
32
            function (EventInterface $e) {
33
                /* @var $cli Application */
34
                $cli = $e->getTarget();
35
36
                /** @var EntityManagerHelper $emHelper */
37
                $emHelper = $cli->getHelperSet()->get('em');
38
39
                $em = $emHelper->getEntityManager();
40
41
                ConsoleRunner::addCommands($cli);
42
43
                $cli->addCommands(
44
                    [
45
                        new GenerateTraitCommand($em),
46
                        new GenerateDataFactoryCommand($em),
47
                        new GenerateTypeScriptInterfaceCommand($em),
48
                    ]
49
                );
50
            }
51
        );
52
    }
53
54
    /**
55
     * {@inheritDoc}
56
     */
57
    public function getConfig()
58
    {
59
        return include __DIR__ . '/../config/module.config.php';
60
    }
61
}
62