- WIP on picea-asset AND fixing ApplicationStrategy allowing PHP-DI caching
This commit is contained in:
parent
3f92287829
commit
4dcc7f407e
|
@ -51,35 +51,7 @@ return [
|
|||
return $breadcrumb;
|
||||
},
|
||||
|
||||
ApplicationStrategy::class => function($c) {
|
||||
return new class($c->get(Picea\Picea::class)) extends ApplicationStrategy {
|
||||
|
||||
public Picea\Picea $picea;
|
||||
|
||||
public function __construct(Picea\Picea $picea) {
|
||||
$this->picea = $picea;
|
||||
}
|
||||
|
||||
public function getNotFoundDecorator(NotFoundException $exception): MiddlewareInterface
|
||||
{
|
||||
return new class($this->picea) implements MiddlewareInterface {
|
||||
|
||||
protected Picea\Picea $picea;
|
||||
|
||||
public function __construct(Picea\Picea $picea) {
|
||||
$this->picea = $picea;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
return new Laminas\Diactoros\Response\HtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
},
|
||||
ApplicationStrategy::class => autowire(\Lean\ApplicationStrategy::class),
|
||||
|
||||
'routes.middlewares' => [ "dump", "errorHandler", SessionMiddleware::class, CronardMiddleware::class, Mcnd\Event\EventMiddleware::class, Mcnd\CLI\CliMiddleware::class, ],
|
||||
|
||||
|
|
|
@ -4,10 +4,19 @@ use function DI\autowire, DI\create, DI\get;
|
|||
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
use Picea\{ Picea, Caching\Cache, Caching\Opcache, Compiler, Compiler\Context, Compiler\BaseContext, FileFetcher, Language\DefaultRegistrations, Method\Request };
|
||||
use Picea\{Asset\Action\InstallActionInterface,
|
||||
Picea,
|
||||
Caching\Cache,
|
||||
Caching\Opcache,
|
||||
Compiler,
|
||||
Compiler\Context,
|
||||
Compiler\BaseContext,
|
||||
FileFetcher,
|
||||
Language\DefaultRegistrations,
|
||||
Method\Request};
|
||||
use Picea\Extension\{ LanguageHandler, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
|
||||
use Picea\Ui\{ Method, Ui };
|
||||
use Picea\Asset\Asset;
|
||||
use Picea\Asset\{ Asset, Action };
|
||||
|
||||
return [
|
||||
Picea::class => function($c) {
|
||||
|
@ -79,4 +88,8 @@ return [
|
|||
FileFetcher::class => function($c) {
|
||||
return new FileFetcher($c->get(Lean\Lean::class)->getViewPaths());
|
||||
},
|
||||
|
||||
Action\Install::class => autowire(Action\Install::class),
|
||||
Action\Symlink::class => autowire(Action\Symlink::class),
|
||||
Action\InstallActionInterface::class => create(Action\Symlink::class),
|
||||
];
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use League\Route\Strategy;
|
||||
|
||||
use League\Route\Http\Exception\NotFoundException;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Picea\Picea;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
class ApplicationStrategy extends Strategy\ApplicationStrategy {
|
||||
|
||||
static array $asset_ext = [
|
||||
"js", "mjs", "manifest", "webmanifest", "css", "png", "ico",
|
||||
"jpg", "jpeg", "gif", "webp", "woff", "woff2", "eot", "svg",
|
||||
"ttf"
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
public Picea $picea
|
||||
) {}
|
||||
|
||||
public function getNotFoundDecorator(NotFoundException $exception): MiddlewareInterface
|
||||
{
|
||||
return new class($this->picea) implements MiddlewareInterface {
|
||||
|
||||
protected Picea $picea;
|
||||
|
||||
public function __construct(Picea $picea)
|
||||
{
|
||||
$this->picea = $picea;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
return $this->throw404($request);
|
||||
}
|
||||
|
||||
public function throw404(ServerRequestInterface $request) : ResponseInterface
|
||||
{
|
||||
if ( class_exists(\Picea\Asset\Asset::class) ) {
|
||||
|
||||
}
|
||||
|
||||
return new \Laminas\Diactoros\Response\HtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
|
@ -110,8 +110,8 @@ class Kernel {
|
|||
|
||||
if (getenv("APP_ENV") === "prod") {
|
||||
if (getenv("CACHE_PATH")) {
|
||||
# $containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/");
|
||||
# $containerBuilder->writeProxiesToFile(true);
|
||||
$containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/");
|
||||
$containerBuilder->writeProxiesToFile(true, getenv("CACHE_PATH") . "/di/proxies/");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue