This repository has been archived by the owner on Jul 25, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
87 lines (76 loc) · 2.09 KB
/
Module.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
/*
* Copyright (c) 2013, Flaming Code
*
*/
namespace FlamingBase;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
/**
* Module
*
* @author Flemming Andersen <[email protected]>
* @copyright (c) 2013, Flaming Code
* @link https://github.com/FlamingCode/FlamingBase for the canonical source repository
* @license http://opensource.org/licenses/MIT MIT
*/
class Module
{
public function getViewHelperConfig()
{
return array(
'factories' => array(
'flashMessenger' => function ($helpers) {
$sm = $helpers->getServiceLocator();
$plugin = $sm->get('ControllerPluginManager')->get('flashmessenger');
return new View\Helper\FlashMessenger($plugin);
},
)
);
}
public function getControllerPluginConfig()
{
return array(
'factories' => array(
'env' => function($helpers) {
$serviceLocator = $helpers->getServiceLocator();
$config = $serviceLocator->get('Configuration');
$envConfig = $config['flamingbase']['env_info'];
$controllerPlugin = new Controller\Plugin\EnvInfo;
if (array_key_exists('env', $envConfig))
$controllerPlugin->setEnv($envConfig['env']);
else
$controllerPlugin->setSearchKeys($envConfig['search_keys']);
return $controllerPlugin;
},
'emailer' => function($helpers) {
$serviceLocator = $helpers->getServiceLocator();
$config = $serviceLocator->get('Configuration');
$controllerPlugin = new Controller\Plugin\Emailer();
$controllerPlugin->setDefaultFrom($config['flamingbase']['emailer']['default_from']);
return $controllerPlugin;
},
)
);
}
public function onBootstrap(MvcEvent $e)
{
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}