1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* @link https://github.com/nnx-framework/container |
4
|
|
|
* @author Malofeykin Andrey <[email protected]> |
5
|
|
|
*/ |
6
|
|
|
namespace Nnx\Container; |
7
|
|
|
|
8
|
|
|
|
9
|
|
|
use Zend\ModuleManager\Feature\ConfigProviderInterface; |
10
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
11
|
|
|
use Zend\Mvc\ModuleRouteListener; |
12
|
|
|
use Zend\Mvc\MvcEvent; |
13
|
|
|
use Zend\EventManager\EventInterface; |
14
|
|
|
use Zend\ModuleManager\Feature\AutoloaderProviderInterface; |
15
|
|
|
use Zend\ModuleManager\Feature\BootstrapListenerInterface; |
16
|
|
|
use Zend\ModuleManager\Feature\InitProviderInterface; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* Class Module |
21
|
|
|
* |
22
|
|
|
* @package Nnx\ContainerOptions |
23
|
|
|
*/ |
24
|
|
|
class Module implements |
25
|
|
|
BootstrapListenerInterface, |
26
|
|
|
AutoloaderProviderInterface, |
27
|
|
|
InitProviderInterface, |
28
|
|
|
ConfigProviderInterface |
29
|
|
|
{ |
30
|
|
|
/** |
31
|
|
|
* Имя секции в конфиги приложения отвечающей за настройки модуля |
32
|
|
|
* |
33
|
|
|
* @var string |
34
|
|
|
*/ |
35
|
|
|
const CONFIG_KEY = 'nnx_container'; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* Имя модуля |
39
|
|
|
* |
40
|
|
|
* @var string |
41
|
|
|
*/ |
42
|
|
|
const MODULE_NAME = __NAMESPACE__; |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @param ModuleManagerInterface $manager |
46
|
|
|
* |
47
|
|
|
* @throws Exception\InvalidArgumentException |
48
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
49
|
|
|
*/ |
50
|
|
|
public function init(ModuleManagerInterface $manager) |
51
|
|
|
{ |
52
|
|
|
|
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @inheritdoc |
57
|
|
|
* |
58
|
|
|
* @param EventInterface $e |
59
|
|
|
* |
60
|
|
|
* @return array|void |
61
|
|
|
* |
62
|
|
|
* @throws \Zend\ServiceManager\Exception\ServiceNotFoundException |
63
|
|
|
*/ |
64
|
|
|
public function onBootstrap(EventInterface $e) |
65
|
|
|
{ |
66
|
|
|
/** @var MvcEvent $e */ |
67
|
|
|
$eventManager = $e->getApplication()->getEventManager(); |
68
|
|
|
$moduleRouteListener = new ModuleRouteListener(); |
69
|
|
|
$moduleRouteListener->attach($eventManager); |
70
|
|
|
|
71
|
|
|
} |
72
|
|
|
|
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @return array |
76
|
|
|
*/ |
77
|
|
|
public function getAutoloaderConfig() |
78
|
|
|
{ |
79
|
|
|
return array( |
80
|
|
|
'Zend\Loader\StandardAutoloader' => array( |
81
|
|
|
'namespaces' => array( |
82
|
|
|
__NAMESPACE__ => __DIR__ . '/src/', |
83
|
|
|
), |
84
|
|
|
), |
85
|
|
|
); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
|
89
|
|
|
/** |
90
|
|
|
* @return mixed |
91
|
|
|
*/ |
92
|
|
|
public function getConfig() |
93
|
|
|
{ |
94
|
|
|
return include __DIR__ . '/config/module.config.php'; |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
} |