|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace App; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* The configuration provider for the App module. |
|
9
|
|
|
* |
|
10
|
|
|
* @see https://docs.zendframework.com/zend-component-installer/ |
|
11
|
|
|
*/ |
|
12
|
|
|
class ConfigProvider |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* Returns the configuration array. |
|
16
|
|
|
* |
|
17
|
|
|
* To add a bit of a structure, each section is defined in a separate |
|
18
|
|
|
* method which returns an array with its configuration. |
|
19
|
|
|
*/ |
|
20
|
|
|
public function __invoke(): array |
|
21
|
|
|
{ |
|
22
|
|
|
return [ |
|
23
|
|
|
'dependencies' => $this->getDependencies(), |
|
24
|
|
|
'templates' => $this->getTemplates(), |
|
25
|
|
|
]; |
|
26
|
|
|
} |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Returns the container dependencies. |
|
30
|
|
|
*/ |
|
31
|
|
|
public function getDependencies(): array |
|
32
|
|
|
{ |
|
33
|
|
|
return [ |
|
34
|
|
|
'invokables' => [ |
|
35
|
|
|
Handler\PingHandler::class => Handler\PingHandler::class, |
|
36
|
|
|
], |
|
37
|
|
|
'factories' => [ |
|
38
|
|
|
Handler\HomePageHandler::class => Handler\HomePageHandlerFactory::class, |
|
39
|
|
|
Handler\ApiTokenLoginHandler::class => Handler\ApiTokenLoginHandlerFactory::class, |
|
40
|
|
|
Handler\ApiTokenValidateHandler::class => Handler\ApiTokenValidateHandlerFactory::class, |
|
41
|
|
|
Handler\ApiContredanseStatusHandler::class => Handler\ApiContredanseStatusHandlerFactory::class, |
|
42
|
|
|
Handler\ApiContredanseProfileHandler::class => Handler\ApiContredanseProfileHandlerFactory::class, |
|
43
|
|
|
|
|
44
|
|
|
// Middleware |
|
45
|
|
|
Middleware\AuthTokenMiddleware::class => Middleware\AuthTokenMiddlewareFactory::class, |
|
46
|
|
|
\Tuupola\Middleware\CorsMiddleware::class => Middleware\ApiCorsMiddlewareFactory::class, |
|
47
|
|
|
|
|
48
|
|
|
// Security |
|
49
|
|
|
// From configured interface |
|
50
|
|
|
Security\UserProviderInterface::class => Security\ContredanseUserProviderFactory::class, |
|
51
|
|
|
// Explicit |
|
52
|
|
|
Security\ContredanseUserProvider::class => Security\ContredanseUserProviderFactory::class, |
|
53
|
|
|
Security\ContredanseProductAccess::class => Security\ContredanseProductAccessFactory::class, |
|
54
|
|
|
|
|
55
|
|
|
// Service |
|
56
|
|
|
Service\Token\TokenManager::class => Service\Token\TokenManagerFactory::class, |
|
57
|
|
|
Service\Auth\AuthManager::class => Service\Auth\AuthManagerFactory::class, |
|
58
|
|
|
|
|
59
|
|
|
// Infrastructure |
|
60
|
|
|
Infra\Db\ContredanseDb::class => Infra\Db\ContredanseDbFactory::class, |
|
61
|
|
|
Infra\Log\AccessLogger::class => Infra\Log\AccessLoggerFactory::class, |
|
62
|
|
|
], |
|
63
|
|
|
]; |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* Returns the templates configuration. |
|
68
|
|
|
*/ |
|
69
|
|
|
public function getTemplates(): array |
|
70
|
|
|
{ |
|
71
|
|
|
return [ |
|
72
|
|
|
'paths' => [ |
|
73
|
|
|
'app' => ['templates/app'], |
|
74
|
|
|
'error' => ['templates/error'], |
|
75
|
|
|
'layout' => ['templates/layout'], |
|
76
|
|
|
], |
|
77
|
|
|
]; |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|