-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathModule.php
85 lines (76 loc) · 2.77 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
<?php
namespace OAuth2Server;
use Laminas\ModuleManager\Feature\AutoloaderProviderInterface;
use Laminas\Mvc\ModuleRouteListener;
use Laminas\Mvc\MvcEvent;
use Laminas\ServiceManager\ServiceManager;
use OAuth2\LaminasHttpPhpEnvironmentBridge\Response;
class Module implements AutoloaderProviderInterface
{
public function getAutoloaderConfig()
{
return [
'Laminas\Loader\StandardAutoloader' => [
'namespaces' => [
// if we're in a namespace deeper than one level we need to fix the \ in the path
__NAMESPACE__ => __DIR__ . '/src/' . str_replace('\\', '/', __NAMESPACE__),
],
],
];
}
/**
* @return array
*/
public function getServiceConfig()
{
return [
'factories' => [
// Override Response factory
'Response' => function (ServiceManager $serviceManager) {
return new Response();
},
'OAuth2Server\Server' => function (ServiceManager $serviceManager) {
$config = $serviceManager->get('Config');
// The grant types and response types will automatically
// be determined based on the interfaces implemented in
// the storage_class
$server = new \OAuth2\Server(
$serviceManager->get('OAuth2Server\Storage'),
$config['oauth2server']['server_config']
);
return $server;
},
'OAuth2Server\Storage' => function (ServiceManager $serviceManager) {
$config = $serviceManager->get('Config');
return new $config['oauth2server']['storage_class']();
},
'OAuth2Server\AuthorizeForm' => function (ServiceManager $serviceManager) {
$config = $serviceManager->get('Config');
$form = new $config['oauth2server']['authorize_form_class'](
'Authorize',
$config['oauth2server']['csrf_salt']
);
return $form;
}
]
];
}
/**
* @return array
*/
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
/**
* @return void
*/
public function onBootstrap(MvcEvent $e)
{
// You may not need to do this if you're doing it elsewhere in your
// application
$eventManager = $e->getApplication()->getEventManager();
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
}
}