1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of phpab/phpab-module. (https://github.com/phpab/phpab-module) |
4
|
|
|
* |
5
|
|
|
* @link https://github.com/phpab/phpab-module for the canonical source repository |
6
|
|
|
* @copyright Copyright (c) 2015-2016 phpab. (https://github.com/phpab/) |
7
|
|
|
* @license https://raw.githubusercontent.com/phpab/phpab-module/master/LICENSE MIT |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace PhpAbModule; |
11
|
|
|
|
12
|
|
|
use PhpAb\Engine\EngineInterface; |
13
|
|
|
use Zend\ModuleManager\Listener\ServiceListener; |
14
|
|
|
use Zend\ModuleManager\ModuleEvent; |
15
|
|
|
use Zend\ModuleManager\ModuleManagerInterface; |
16
|
|
|
use Zend\ServiceManager\ServiceManager; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* The Module class which is used to be loaded into a Zend Framework 2 application. |
20
|
|
|
*/ |
21
|
|
|
class Module |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* Gets the configuration for this module. |
25
|
|
|
* |
26
|
|
|
* @return array |
27
|
|
|
*/ |
28
|
|
|
public function getConfig() |
29
|
|
|
{ |
30
|
|
|
return include __DIR__ . '/../config/module.config.php'; |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
/** |
34
|
|
|
* Initializes the module. |
35
|
|
|
* |
36
|
|
|
* @param ModuleManagerInterface $moduleManager |
37
|
|
|
*/ |
38
|
|
|
public function init(ModuleManagerInterface $moduleManager) |
39
|
|
|
{ |
40
|
|
|
$eventManager = $moduleManager->getEventManager(); |
41
|
|
|
$eventManager->attach(ModuleEvent::EVENT_LOAD_MODULES_POST, array($this, 'onLoadModulesPost')); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* Called when the modules are loaded. |
46
|
|
|
* |
47
|
|
|
* @param ModuleEvent $event |
48
|
|
|
*/ |
49
|
|
|
public function onLoadModulesPost(ModuleEvent $event) |
50
|
|
|
{ |
51
|
|
|
/** @var ServiceManager $serviceManager */ |
52
|
|
|
$serviceManager = $event->getParam('ServiceManager'); |
53
|
|
|
|
54
|
|
|
/** @var EngineInterface $engine */ |
55
|
|
|
$engine = $serviceManager->get('phpab.engine'); |
56
|
|
|
$engine->start(); |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|