forked from Webador/JwPersistentUser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
48 lines (40 loc) · 1.3 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
<?php
namespace JwPersistentUser;
use JwPersistentUser\Service\CookieAuthenticationService;
use Zend\EventManager\EventInterface;
use Zend\EventManager\EventManager;
use Zend\ModuleManager\Feature;
use Zend\ServiceManager\ServiceManager;
class Module implements
Feature\ConfigProviderInterface,
Feature\BootstrapListenerInterface,
Feature\AutoloaderProviderInterface
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function onBootstrap(EventInterface $e)
{
/** @var EventManager $em */
$em = $e->getApplication()->getEventManager();
/** @var ServiceManager $sm */
$sm = $e->getApplication()->getServiceManager();
$request = $e->getApplication()->getRequest();
$response = $e->getApplication()->getResponse();
// Try to login from Cookie if applicable
$service = new CookieAuthenticationService($sm);
$service->setEventManager($em);
$service->loginFrom($request, $response);
}
public function getAutoloaderConfig()
{
return [
'Zend\Loader\StandardAutoloader' => [
'namespaces' => [
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
],
],
];
}
}