|
1
|
|
|
<?php |
|
2
|
|
|
declare(strict_types=1); |
|
3
|
|
|
|
|
4
|
|
|
namespace SlayerBirden\DataFlowServer\Authorization; |
|
5
|
|
|
|
|
6
|
|
|
use Psr\Log\LoggerInterface; |
|
7
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Controller\GetResourcesAction; |
|
8
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Controller\SavePermissionsAction; |
|
9
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Factory\PermissionHydratorFactory; |
|
10
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Repository\PermissionRepository; |
|
11
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Service\HistoryManagement; |
|
12
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Service\PermissionManager; |
|
13
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Service\ResourceManager; |
|
14
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Validation\ResourceValidator; |
|
15
|
|
|
use SlayerBirden\DataFlowServer\Authorization\Validation\ResourceValidatorFactory; |
|
16
|
|
|
use SlayerBirden\DataFlowServer\Doctrine\Persistence\EntityManagerRegistry; |
|
17
|
|
|
use SlayerBirden\DataFlowServer\Zend\InputFilter\ProxyFilterManagerFactory; |
|
18
|
|
|
use Zend\Expressive\Application; |
|
19
|
|
|
use Zend\Expressive\Router\RouteCollector; |
|
20
|
|
|
use Zend\ServiceManager\AbstractFactory\ConfigAbstractFactory; |
|
21
|
|
|
use Zend\Validator\NotEmpty; |
|
22
|
|
|
|
|
23
|
|
|
class ConfigProvider |
|
24
|
|
|
{ |
|
25
|
|
|
public function __invoke(): array |
|
26
|
|
|
{ |
|
27
|
|
|
return [ |
|
28
|
|
|
ConfigAbstractFactory::class => $this->getAbstractFactoryConfig(), |
|
29
|
|
|
'doctrine' => $this->getDoctrineConfig(), |
|
30
|
|
|
'dependencies' => $this->getDependenciesConfig(), |
|
31
|
|
|
'validators' => $this->getValidatorsConfig(), |
|
32
|
|
|
'input_filter_specs' => [ |
|
33
|
|
|
'PermissionsInputFilter' => $this->getPermissionsInputFilterSpec(), |
|
34
|
|
|
], |
|
35
|
|
|
]; |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
private function getPermissionsInputFilterSpec(): array |
|
39
|
|
|
{ |
|
40
|
|
|
return [ |
|
41
|
|
|
'resources' => [ |
|
42
|
|
|
'validators' => [ |
|
43
|
|
|
[ |
|
44
|
|
|
'name' => 'notEmpty', |
|
45
|
|
|
'break_chain_on_failure' => true, |
|
46
|
|
|
'options' => [ |
|
47
|
|
|
'type' => NotEmpty::BOOLEAN | NotEmpty::NULL | NotEmpty::STRING |
|
48
|
|
|
] |
|
49
|
|
|
], |
|
50
|
|
|
[ |
|
51
|
|
|
'name' => 'resourcesValidator', |
|
52
|
|
|
], |
|
53
|
|
|
], |
|
54
|
|
|
], |
|
55
|
|
|
]; |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
private function getAbstractFactoryConfig(): array |
|
59
|
|
|
{ |
|
60
|
|
|
return [ |
|
61
|
|
|
PermissionRepository::class => [ |
|
62
|
|
|
EntityManagerRegistry::class, |
|
63
|
|
|
], |
|
64
|
|
|
PermissionManager::class => [ |
|
65
|
|
|
PermissionRepository::class, |
|
66
|
|
|
], |
|
67
|
|
|
ResourceManager::class => [ |
|
68
|
|
|
RouteCollector::class, |
|
69
|
|
|
], |
|
70
|
|
|
GetResourcesAction::class => [ |
|
71
|
|
|
ResourceManagerInterface::class, |
|
72
|
|
|
], |
|
73
|
|
|
HistoryManagement::class => [ |
|
74
|
|
|
EntityManagerRegistry::class, |
|
75
|
|
|
], |
|
76
|
|
|
SavePermissionsAction::class => [ |
|
77
|
|
|
EntityManagerRegistry::class, |
|
78
|
|
|
PermissionRepository::class, |
|
79
|
|
|
LoggerInterface::class, |
|
80
|
|
|
'PermissionsInputFilter', |
|
81
|
|
|
HistoryManagementInterface::class, |
|
82
|
|
|
'PermissionHydrator', |
|
83
|
|
|
], |
|
84
|
|
|
]; |
|
85
|
|
|
} |
|
86
|
|
|
|
|
87
|
|
|
private function getDoctrineConfig(): array |
|
88
|
|
|
{ |
|
89
|
|
|
return [ |
|
90
|
|
|
'entity_managers' => [ |
|
91
|
|
|
'default' => [ |
|
92
|
|
|
'paths' => [ |
|
93
|
|
|
'src/Authorization/Entities', |
|
94
|
|
|
], |
|
95
|
|
|
], |
|
96
|
|
|
], |
|
97
|
|
|
]; |
|
98
|
|
|
} |
|
99
|
|
|
|
|
100
|
|
|
private function getDependenciesConfig(): array |
|
101
|
|
|
{ |
|
102
|
|
|
return [ |
|
103
|
|
|
'delegators' => [ |
|
104
|
|
|
Application::class => [ |
|
105
|
|
|
Factory\RoutesDelegator::class, |
|
106
|
|
|
], |
|
107
|
|
|
], |
|
108
|
|
|
'aliases' => [ |
|
109
|
|
|
PermissionManagerInterface::class => PermissionManager::class, |
|
110
|
|
|
ResourceManagerInterface::class => ResourceManager::class, |
|
111
|
|
|
HistoryManagementInterface::class => HistoryManagement::class, |
|
112
|
|
|
], |
|
113
|
|
|
'factories' => [ |
|
114
|
|
|
'PermissionsInputFilter' => ProxyFilterManagerFactory::class, |
|
115
|
|
|
'PermissionHydrator' => PermissionHydratorFactory::class, |
|
116
|
|
|
], |
|
117
|
|
|
]; |
|
118
|
|
|
} |
|
119
|
|
|
|
|
120
|
|
|
private function getValidatorsConfig(): array |
|
121
|
|
|
{ |
|
122
|
|
|
return [ |
|
123
|
|
|
'aliases' => [ |
|
124
|
|
|
'resourcesValidator' => ResourceValidator::class, |
|
125
|
|
|
'resourceValidator' => ResourceValidator::class, |
|
126
|
|
|
], |
|
127
|
|
|
'factories' => [ |
|
128
|
|
|
ResourceValidator::class => ResourceValidatorFactory::class, |
|
129
|
|
|
], |
|
130
|
|
|
]; |
|
131
|
|
|
} |
|
132
|
|
|
} |
|
133
|
|
|
|