forked from bgallagher/BgOauthProvider
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathModule.php
executable file
·101 lines (88 loc) · 3.47 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
namespace BgOauthProvider;
use Zend\ModuleManager\Feature\AutoloaderProviderInterface;
use Zend\ModuleManager\Feature\ServiceProviderInterface;
use Zend\Mvc\MvcEvent;
use Zend\Mvc\Controller\ControllerManager;
class Module implements AutoloaderProviderInterface, ServiceProviderInterface
{
public function onBootstrap(MvcEvent $event)
{
$app = $event->getApplication();
$events = $app->getEventManager();
$sm = $app->getServiceManager();
$events->attach($sm->get('BgOauthRouteGuard'));
}
public function getAutoloaderConfig()
{
return array(
'Zend\Loader\ClassMapAutoloader' => array(
__DIR__ . '/autoload_classmap.php',
),
'Zend\Loader\StandardAutoloader' => array(
'namespaces' => array(
__NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getServiceConfig()
{
return array(
'factories' => array(
'BgOauthService' => function ($serviceLocator) {
return new \BgOauthProvider\Service\Oauth(
$serviceLocator->get('doctrine.entitymanager.orm_default')
);
},
'BgAppService' => function ($serviceLocator) {
return new \BgOauthProvider\Service\App(
$serviceLocator->get('doctrine.entitymanager.orm_default')
);
},
'BgOauthProvider' => function ($serviceLocator) {
return new \BgOauthProvider\Oauth\Provider(
$serviceLocator->get('BgOauthService'),
$serviceLocator->get('BgAppService'),
$serviceLocator->get('BgTokenEntityConcrete')
);
},
'BgOauthAcl' => function ($serviceLocator) {
$config = $serviceLocator->get('Configuration');
$aclConfig = array_key_exists('BgOauthAcl', $config) ? $config['BgOauthAcl'] : array();
return new \BgOauthProvider\Acl($aclConfig);
},
'BgOauthRouteGuard' => function ($serviceLocator) {
return new \BgOauthProvider\Guard\Route(
$serviceLocator->get('BgOauthAcl'),
$serviceLocator->get('BgOauthProvider')
);
},
),
'invokables' => array(
'BgTokenEntityConcrete' => 'BgOauthProvider\Entity\Token',
),
'shared' => array(
'BgTokenEntityConcrete' => false,
),
);
}
public function getControllerConfig()
{
return array(
'factories' => array(
'BgOauthProvider\Controller\Oauth' => function(ControllerManager $controllerManager) {
$serviceManager = $controllerManager->getServiceLocator();
$controller = new \BgOauthProvider\Controller\OauthController();
$controller->setOauthService($serviceManager->get('BgOauthService'));
$controller->setOauthProvider($serviceManager->get('BgOauthProvider'));
return $controller;
}
),
);
}
}