-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
59 lines (49 loc) · 1.52 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
<?php
namespace MvlabsEventLogger;
use Zend\Mvc\MvcEvent;
use Zend\ModuleManager\ModuleManagerInterface;
class Module
{
public function onBootstrap(MvcEvent $e)
{
$em = $e->getApplication()->getEventManager();
$em->attach('dispatch', array($this, 'onDispatch'), 1000);
}
public function onDispatch (MvcEvent $e)
{
$application = $e->getApplication();
$serviceManager = $application->getServiceManager();
// attach event logger listener (only if a user is logged)
$auth = $serviceManager->get('zfcuser_auth_service');
if ($auth->hasIdentity()) {
$sharedEventManager = $application->getEventManager()->getSharedManager();
$sharedEventManager->attachAggregate(
$serviceManager->get(
'MvlabsEventLogger\Listener\UserEventListener'));
}
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig ()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__
]
]
];
}
public function getServiceConfig()
{
return [
'invokables' => [
],
'factories' => [
'MvlabsEventLogger\Service\UserEventService' => 'MvlabsEventLogger\Service\UserEventServiceFactory',
]
];
}
}