-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathModule.php
More file actions
82 lines (67 loc) · 2.46 KB
/
Module.php
File metadata and controls
82 lines (67 loc) · 2.46 KB
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
<?php
namespace Cms;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$e->getApplication()->getServiceManager()->get('translator');
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
// Set the timezone
ini_set('date.timezone', 'America/Chicago');
}
public function getConfig()
{
$config = include __DIR__ . '/config/module.config.php';
// Get the cms page routes from a cache file
if (!empty($config['routeCacheFile'])
&& file_exists($config['routeCacheFile'])) {
$cachedRoutes = file_get_contents($config['routeCacheFile']);
$config['router']['routes']['cmsPage']['options']
['constraints']['pageRoute'] = $cachedRoutes;
}
return $config;
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/Nhebi/' . __NAMESPACE__,
),
),
);
}
public function getServiceConfig()
{
return array(
'abstract_factories' => array(),
'aliases' => array(),
'invokables' => array(),
'services' => array(),
'factories' => array(
'model.page' => function ($sm) {
$pageModel = new \Cms\Model\Page;
$em = $sm->get('doctrine.entitymanager.orm_default');
$pageModel->setEntityManager($em);
return $pageModel;
},
'service.routeCache' => function ($sm) {
$routeCacheService = new \Cms\Service\RouteCache;
// Inject the page model
$pageModel = $sm->get('model.page');
$routeCacheService->setPageModel($pageModel);
// Grab the cache file from the config and pass it in
$config = $sm->get('Config');
if (!empty($config['routeCacheFile'])) {
$routeCacheService->setCacheFile($config['routeCacheFile']);
}
return $routeCacheService;
},
),
);
}
}