Module::getAutoloaderConfig()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 10
nc 2
nop 0
1
<?php
2
/**
3
 * @link https://github.com/old-town/workflow-doctrine-zf2
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Doctrine\ZF2;
7
8
9
use Zend\Mvc\ModuleRouteListener;
10
use Zend\Mvc\MvcEvent;
11
use Zend\EventManager\EventInterface;
12
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
13
use Zend\ModuleManager\Feature\ConfigProviderInterface;
14
use Zend\ModuleManager\Feature\BootstrapListenerInterface;
15
16
17
/**
18
 * Class Module
19
 *
20
 * @package OldTown\Workflow\Doctrine\ZF2
21
 */
22
class Module implements
23
    BootstrapListenerInterface,
24
    ConfigProviderInterface,
25
    AutoloaderProviderInterface
26
{
27
    /**
28
     * @param EventInterface $e
29
     *
30
     * @return array|void
31
     * @throws \Zend\ServiceManager\Exception\ServiceNotFoundException
32
     */
33
    public function onBootstrap(EventInterface $e)
34
    {
35
        /** @var MvcEvent $e */
36
        $eventManager        = $e->getApplication()->getEventManager();
37
        $moduleRouteListener = new ModuleRouteListener();
38
        $moduleRouteListener->attach($eventManager);
39
40
        $sl = $e->getApplication()->getServiceManager();
41
        EntityManagerFactory::setDefaultServiceLocator($sl);
42
    }
43
44
    /**
45
     * @return array
46
     */
47
    public function getConfig()
48
    {
49
        return include __DIR__ . '/config/module.config.php';
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function getAutoloaderConfig()
56
    {
57
        $config = [];
58
        $autoloadFile = __DIR__ . '/autoload_classmap.php';
59
        if (file_exists($autoloadFile)) {
60
            $config['Zend\Loader\ClassMapAutoloader'] = [
61
                    $autoloadFile,
62
                ];
63
        }
64
        $config['Zend\Loader\StandardAutoloader'] = [
65
                'namespaces' => [
66
                    __NAMESPACE__ => __DIR__ . '/src',
67
                ],
68
        ];
69
        return $config;
70
    }
71
}