2022-03-31 06:34:30 +00:00
|
|
|
<?php declare(strict_types=1);
|
|
|
|
|
|
|
|
use FastRoute\Dispatcher;
|
|
|
|
use Laminas\Diactoros\ResponseFactory;
|
|
|
|
use Lubian\NoFramework\Factory\DiactorosRequestFactory;
|
|
|
|
use Lubian\NoFramework\Factory\PipelineProvider;
|
|
|
|
use Lubian\NoFramework\Factory\RequestFactory;
|
|
|
|
use Lubian\NoFramework\Http\BasicEmitter;
|
|
|
|
use Lubian\NoFramework\Http\Emitter;
|
|
|
|
use Lubian\NoFramework\Http\InvokerRoutedHandler;
|
|
|
|
use Lubian\NoFramework\Http\Pipeline;
|
|
|
|
use Lubian\NoFramework\Http\RoutedRequestHandler;
|
|
|
|
use Lubian\NoFramework\Http\RouteMiddleware;
|
2022-04-06 21:43:03 +00:00
|
|
|
use Lubian\NoFramework\Repository\CachedMarkdownPageRepo;
|
2022-04-05 23:21:17 +00:00
|
|
|
use Lubian\NoFramework\Repository\FileSystemMarkdownPageRepo;
|
2022-03-31 06:34:30 +00:00
|
|
|
use Lubian\NoFramework\Repository\MarkdownPageRepo;
|
2022-04-06 21:43:03 +00:00
|
|
|
use Lubian\NoFramework\Service\Cache\ApcuCache;
|
|
|
|
use Lubian\NoFramework\Service\Cache\EasyCache;
|
2022-03-31 06:34:30 +00:00
|
|
|
use Lubian\NoFramework\Service\Time\Now;
|
|
|
|
use Lubian\NoFramework\Service\Time\SystemClockNow;
|
|
|
|
use Lubian\NoFramework\Settings;
|
2022-04-05 17:09:40 +00:00
|
|
|
use Lubian\NoFramework\Template\MarkdownParser;
|
2022-03-31 06:34:30 +00:00
|
|
|
use Lubian\NoFramework\Template\MustacheRenderer;
|
2022-04-05 17:09:40 +00:00
|
|
|
use Lubian\NoFramework\Template\ParsedownParser;
|
2022-03-31 06:34:30 +00:00
|
|
|
use Lubian\NoFramework\Template\Renderer;
|
|
|
|
use Mustache_Engine as ME;
|
|
|
|
use Mustache_Loader_FilesystemLoader as MLF;
|
|
|
|
use Psr\Http\Message\ResponseFactoryInterface;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
|
|
use Psr\Http\Server\MiddlewareInterface;
|
|
|
|
|
|
|
|
use function FastRoute\simpleDispatcher;
|
|
|
|
|
|
|
|
return [
|
2022-04-04 22:02:52 +00:00
|
|
|
// alias
|
|
|
|
Now::class => fn (SystemClockNow $n) => $n,
|
|
|
|
ResponseFactoryInterface::class => fn (ResponseFactory $rf) => $rf,
|
|
|
|
Emitter::class => fn (BasicEmitter $e) => $e,
|
|
|
|
MiddlewareInterface::class => fn (RouteMiddleware $r) => $r,
|
|
|
|
RoutedRequestHandler::class => fn (InvokerRoutedHandler $h) => $h,
|
|
|
|
RequestFactory::class => fn (DiactorosRequestFactory $rf) => $rf,
|
2022-04-05 17:09:40 +00:00
|
|
|
MarkdownParser::class => fn (ParsedownParser $p) => $p,
|
2022-04-06 21:43:03 +00:00
|
|
|
MarkdownPageRepo::class => fn (CachedMarkdownPageRepo $r) => $r,
|
|
|
|
EasyCache::class => fn (ApcuCache $c) => $c,
|
|
|
|
CachedMarkdownPageRepo::class => fn (EasyCache $c, FileSystemMarkdownPageRepo $r) => new CachedMarkdownPageRepo($c, $r),
|
|
|
|
|
2022-04-04 22:02:52 +00:00
|
|
|
|
|
|
|
// Factories
|
2022-03-31 06:34:30 +00:00
|
|
|
ResponseInterface::class => fn (ResponseFactory $rf) => $rf->createResponse(),
|
|
|
|
ServerRequestInterface::class => fn (RequestFactory $rf) => $rf->fromGlobals(),
|
|
|
|
Renderer::class => fn (Mustache_Engine $e) => new MustacheRenderer($e),
|
|
|
|
MLF::class => fn (Settings $s) => new MLF($s->templateDir, ['extension' => $s->templateExtension]),
|
|
|
|
ME::class => fn (MLF $mfl) => new ME(['loader' => $mfl]),
|
|
|
|
Dispatcher::class => fn () => simpleDispatcher(require __DIR__ . '/routes.php'),
|
|
|
|
Pipeline::class => fn (PipelineProvider $p) => $p->getPipeline(),
|
2022-04-05 23:21:17 +00:00
|
|
|
FileSystemMarkdownPageRepo::class => fn (Settings $s) => new FileSystemMarkdownPageRepo($s->pagesPath),
|
2022-03-31 06:34:30 +00:00
|
|
|
];
|