2021-03-01 16:01:27 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
use Picea\Picea;
|
|
|
|
|
2023-03-29 13:59:59 +00:00
|
|
|
use Negundo\Client\{ NegundoMiddleware, SoftwareConfig };
|
|
|
|
|
2024-08-30 18:59:17 +00:00
|
|
|
use Lean\Factory\HttpFactory;
|
2021-03-01 16:01:27 +00:00
|
|
|
|
|
|
|
use Psr\Http\Server\MiddlewareInterface,
|
|
|
|
Psr\Http\Message\ServerRequestInterface,
|
|
|
|
Psr\Http\Server\RequestHandlerInterface,
|
|
|
|
Psr\Http\Message\ResponseInterface;
|
|
|
|
|
|
|
|
use function DI\{ create, get, autowire };
|
|
|
|
|
|
|
|
error_reporting(getenv('ERROR_REPORTING') ?: ( E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE ));
|
|
|
|
|
|
|
|
return [
|
|
|
|
/* do nothing in production !*/
|
|
|
|
"dump" => function($c) {
|
|
|
|
if (! function_exists('dump') ) {
|
|
|
|
function dump(...$what) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
return new class implements MiddlewareInterface {
|
|
|
|
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface { return $handler->handle($request); }
|
|
|
|
};
|
|
|
|
},
|
|
|
|
|
2023-03-29 13:59:59 +00:00
|
|
|
SoftwareConfig::class => create(SoftwareConfig::class)->constructor(getenv('NEGUNDO_HASH'), getenv('NEGUNDO_SERVER')),
|
|
|
|
|
|
|
|
"errorHandler" => create(NegundoMiddleware::class)->constructor(get(SoftwareConfig::class), null, get('app.errorhandler.html')),
|
2021-03-01 16:01:27 +00:00
|
|
|
|
|
|
|
'app.errorhandler.html' => function($c, Picea $picea) {
|
|
|
|
return function(\Throwable $exception) use ($picea) {
|
2023-02-08 16:36:16 +00:00
|
|
|
error_log($exception->getMessage());
|
|
|
|
|
2024-08-30 18:59:17 +00:00
|
|
|
return HttpFactory::createHtmlResponse($picea->renderHtml('lean/error/500', [
|
2021-03-01 16:01:27 +00:00
|
|
|
'title' => "Une erreur s'est produite lors de l'exécution du script.",
|
|
|
|
'subtitle' => "Êtes-vous connecté avec le bon compte ?",
|
|
|
|
'message' => $exception->getMessage(),
|
|
|
|
'exception' => $exception,
|
2023-05-31 18:41:02 +00:00
|
|
|
]), 500);
|
2021-03-01 16:01:27 +00:00
|
|
|
};
|
|
|
|
},
|
2023-01-26 13:28:36 +00:00
|
|
|
|
|
|
|
'routes.caching' => create(Kash\ApcuCache::class)->constructor(get(Kash\CacheInvalidator::class), "lean.routes", random_int(3600, 7200)),
|
|
|
|
'breadcrumbs.caching' => create(Kash\ApcuCache::class)->constructor(get(Kash\CacheInvalidator::class), "lean.breadcrumbs", random_int(3600, 7200)),
|
|
|
|
'ulmus.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "ulmus.entities", random_int(3600, 7200)),
|
2023-01-27 15:42:33 +00:00
|
|
|
'cronard.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.cronards", random_int(3600, 7200)),
|
2023-03-29 13:59:59 +00:00
|
|
|
'events.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.events", random_int(3600, 7200)),
|
2023-07-09 16:37:39 +00:00
|
|
|
'cli.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.cli", random_int(3600, 7200)),
|
2023-01-26 13:28:36 +00:00
|
|
|
];
|