|
19 | 19 | use Xsga\FilmAffinityApi\Modules\Films\Application\Mappers\GenreToGenreDto; |
20 | 20 | use Xsga\FilmAffinityApi\Modules\Films\Application\Services\BackupCountriesService; |
21 | 21 | use Xsga\FilmAffinityApi\Modules\Films\Application\Services\BackupGenresService; |
22 | | -use Xsga\FilmAffinityApi\Modules\Films\Domain\Parsers\AdvancedSearchFormParser; |
23 | | -use Xsga\FilmAffinityApi\Modules\Films\Domain\Parsers\AdvancedSearchParser; |
24 | 22 | use Xsga\FilmAffinityApi\Modules\Films\Domain\Repositories\AdvancedSearchRepository; |
25 | 23 | use Xsga\FilmAffinityApi\Modules\Films\Domain\Repositories\CountriesRepository; |
26 | 24 | use Xsga\FilmAffinityApi\Modules\Films\Domain\Repositories\FilmsRepository; |
|
63 | 61 | // -------------------------------------------------------------------------------------------- |
64 | 62 |
|
65 | 63 | // FOLDERS. |
66 | | - 'root.folder' => getPathTo(), |
67 | | - 'entity.folders' => [getPathTo('src#Xsga#FilmAffinityApi#Modules#Shared#Persistence#Infrastructure#Doctrine')], |
68 | | - 'schema.folder' => getPathTo('config#schemas#input'), |
69 | | - 'backup.folder' => getPathTo('data#backup'), |
| 64 | + 'root.folder' => getPathTo(), |
| 65 | + 'entity.folders' => [ |
| 66 | + getPathTo('src#Xsga#FilmAffinityApi#Modules#Shared#Persistence#Infrastructure#Doctrine'), |
| 67 | + ], |
| 68 | + 'schema.folder' => getPathTo('config#schemas#input'), |
| 69 | + 'backup.folder' => getPathTo('data#backup'), |
70 | 70 | 'entities.proxy.folder' => getPathTo('tmp#doctrine-proxies'), |
71 | | - 'logger.config.folder' => getPathTo('config#logger'), |
72 | | - 'errors.folder' => getPathTo('config#errors'), |
73 | | - 'cache.folder' => getPathTo('tmp#cache'), |
| 71 | + 'logger.config.folder' => getPathTo('config#logger'), |
| 72 | + 'errors.folder' => getPathTo('config#errors'), |
| 73 | + 'cache.folder' => getPathTo('tmp#cache'), |
74 | 74 |
|
75 | 75 | // ENVIRONMENT. |
76 | | - 'getLanguage' => $_ENV['LANGUAGE'], |
77 | | - 'getErrorDetail' => filter_var($_ENV['ERROR_DETAIL'], FILTER_VALIDATE_BOOLEAN), |
78 | | - 'getLogSQL' => filter_var($_ENV['LOG_SQL'], FILTER_VALIDATE_BOOLEAN), |
79 | | - 'getUrlPath' => $_ENV['URL_PATH'], |
80 | | - 'getJwtSecretKey' => $_ENV['JWT_SECRET_KEY'], |
81 | | - 'getJwtLifetime' => (int)$_ENV['JWT_LIFETIME'], |
82 | | - 'getSecurityType' => function () { |
| 76 | + 'env.language' => $_ENV['LANGUAGE'], |
| 77 | + 'env.error.detail' => filter_var($_ENV['ERROR_DETAIL'], FILTER_VALIDATE_BOOLEAN), |
| 78 | + 'env.log.sql' => filter_var($_ENV['LOG_SQL'], FILTER_VALIDATE_BOOLEAN), |
| 79 | + 'env.url.path' => $_ENV['URL_PATH'], |
| 80 | + 'env.jwt.secret.key' => $_ENV['JWT_SECRET_KEY'], |
| 81 | + 'env.jwt.lifetime' => (int)$_ENV['JWT_LIFETIME'], |
| 82 | + 'env.security.type' => function (): SecurityTypes { |
83 | 83 | return match ($_ENV['SECURITY_TYPE']) { |
84 | 84 | 'basic' => SecurityTypes::BASIC, |
85 | 85 | 'token' => SecurityTypes::TOKEN |
86 | 86 | }; |
87 | 87 | }, |
88 | | - 'getDateMask' => 'd/m/Y', |
89 | | - 'getDateTimeMask' => 'd/m/Y H:i:s', |
90 | | - 'database.info' => [ |
| 88 | + 'env.date.mask' => 'd/m/Y', |
| 89 | + 'env.datetime.mask' => 'd/m/Y H:i:s', |
| 90 | + 'env.database.info' => [ |
91 | 91 | 'driver' => 'pdo_mysql', |
92 | 92 | 'dbname' => $_ENV['DB_SCHEMA'], |
93 | 93 | 'user' => $_ENV['DB_USER'], |
|
98 | 98 | ], |
99 | 99 |
|
100 | 100 | // FILMAFFINITY. |
101 | | - 'filmaffinity.baseURL' => $_ENV['BASE_URL'], |
102 | | - 'filmaffinity.searchURL' => $_ENV['SEARCH_URL'], |
| 101 | + 'filmaffinity.baseURL' => $_ENV['BASE_URL'], |
| 102 | + 'filmaffinity.searchURL' => $_ENV['SEARCH_URL'], |
103 | 103 | 'filmaffinity.advancedSearchURL' => $_ENV['ADV_SEARCH_URL'], |
104 | | - 'filmaffinity.filmURL' => $_ENV['FILM_URL'], |
105 | | - 'filmaffinity.getBaseURL' => function (ContainerInterface $container): string { |
106 | | - return match (strtolower($container->get('getLanguage'))) { |
| 104 | + 'filmaffinity.filmURL' => $_ENV['FILM_URL'], |
| 105 | + 'filmaffinity.getBaseURL' => function (ContainerInterface $container): string { |
| 106 | + return match (strtolower($container->get('env.language'))) { |
107 | 107 | 'spa' => $container->get('filmaffinity.baseURL') . 'es/', |
108 | 108 | 'en' => $container->get('filmaffinity.baseURL') . 'us/' |
109 | 109 | }; |
|
112 | 112 | // -------------------------------------------------------------------------------------------- |
113 | 113 | // ENTITY MANAGER. |
114 | 114 | // -------------------------------------------------------------------------------------------- |
115 | | - EntityManagerInterface::class => function (ContainerInterface $container) { |
| 115 | + EntityManagerInterface::class => function (ContainerInterface $container): EntityManager { |
116 | 116 | $isDevMode = true; |
117 | 117 | $entityPaths = $container->get('entity.folders'); |
118 | 118 | $proxyPath = $container->get('entities.proxy.folder'); |
119 | 119 |
|
120 | 120 | $config = ORMSetup::createAttributeMetadataConfiguration($entityPaths, $isDevMode, $proxyPath, null); |
121 | 121 | $config->setAutoGenerateProxyClasses($isDevMode); |
122 | 122 |
|
123 | | - if ($container->get('getLogSQL')) { |
| 123 | + if ($container->get('env.log.sql')) { |
124 | 124 | $config->setMiddlewares([$container->get(Middleware::class)]); |
125 | 125 | } |
126 | 126 |
|
127 | | - $connection = DriverManager::getConnection($container->get('database.info'), $config); |
| 127 | + $connection = DriverManager::getConnection($container->get('env.database.info'), $config); |
128 | 128 |
|
129 | 129 | return new EntityManager($connection, $config); |
130 | 130 | }, |
131 | 131 |
|
132 | 132 | // -------------------------------------------------------------------------------------------- |
133 | 133 | // LOGGER. |
134 | 134 | // -------------------------------------------------------------------------------------------- |
135 | | - Logger::class => function (ContainerInterface $container) { |
| 135 | + Logger::class => function (ContainerInterface $container): Logger { |
136 | 136 | if (!Logger::isInitialized()) { |
137 | 137 | Logger::configure($container->get('logger.config.folder') . 'log4php.xml'); |
138 | 138 | } |
139 | 139 | return Logger::getRootLogger(); |
140 | 140 | }, |
141 | | - 'logger-cli' => function (ContainerInterface $container) { |
| 141 | + 'logger-cli' => function (ContainerInterface $container): Logger { |
142 | 142 | if (!Logger::isInitialized()) { |
143 | 143 | Logger::configure($container->get('logger.config.folder') . 'log4php-cli.xml'); |
144 | 144 | } |
145 | 145 | return Logger::getRootLogger(); |
146 | 146 | }, |
147 | | - LoggerInterface::class => function (ContainerInterface $container): LoggerInterface { |
| 147 | + LoggerInterface::class => function (ContainerInterface $container): LoggerWrapper { |
148 | 148 | $logger = match (php_sapi_name()) { |
149 | 149 | 'cli' => $container->get('logger-cli'), |
150 | 150 | default => $container->get(Logger::class) |
|
162 | 162 | DI\get(GetSchemaService::class), |
163 | 163 | DI\get(JsonLoaderService::class), |
164 | 164 | DI\get('errors.folder'), |
165 | | - DI\get('getLanguage'), |
| 165 | + DI\get('env.language'), |
166 | 166 | DI\get(JsonErrorToError::class) |
167 | 167 | ), |
168 | 168 |
|
|
172 | 172 |
|
173 | 173 | // Application mappers. |
174 | 174 | UserToUserDto::class => DI\create(UserToUserDto::class)->constructor( |
175 | | - DI\get('getDateTimeMask') |
| 175 | + DI\get('env.datetime.mask') |
176 | 176 | ), |
177 | 177 |
|
178 | 178 | // Domain repositories. |
|
192 | 192 | DI\get(LoggerInterface::class), |
193 | 193 | DI\get(FilmAffinityGenresRepository::class), |
194 | 194 | DI\get(GenreToGenreDto::class), |
195 | | - DI\get('getLanguage'), |
| 195 | + DI\get('env.language'), |
196 | 196 | DI\get('backup.folder') |
197 | 197 | ), |
198 | 198 |
|
199 | 199 | BackupCountriesService::class => DI\create(BackupCountriesService::class)->constructor( |
200 | 200 | DI\get(LoggerInterface::class), |
201 | 201 | DI\get(FilmAffinityCountriesRepository::class), |
202 | 202 | DI\get(CountryToCountryDto::class), |
203 | | - DI\get('getLanguage'), |
| 203 | + DI\get('env.language'), |
204 | 204 | DI\get('backup.folder') |
205 | 205 | ), |
206 | 206 |
|
|
262 | 262 | // JWT application services. |
263 | 263 | JWTService::class => DI\create(FirebaseJwtService::class)->constructor( |
264 | 264 | DI\get(LoggerInterface::class), |
265 | | - DI\get('getJwtSecretKey'), |
266 | | - DI\get('getJwtLifetime') |
| 265 | + DI\get('env.jwt.secret.key'), |
| 266 | + DI\get('env.jwt.lifetime') |
267 | 267 | ), |
268 | 268 |
|
269 | 269 | // HTTP CLIENT application services. |
|
277 | 277 | DI\get(LoggerInterface::class), |
278 | 278 | DI\get(BasicSecurityService::class), |
279 | 279 | DI\get(TokenSecurityService::class), |
280 | | - DI\get('getSecurityType') |
| 280 | + DI\get('env.security.type') |
281 | 281 | ), |
282 | 282 | ]; |
0 commit comments