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