- WIP on picea-asset AND fixing ApplicationStrategy allowing PHP-DI caching
This commit is contained in:
1 parent
3f92287829
commit
4dcc7f407e
4 files changed
+70
-33
No files matched your search
@@ -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);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+2
-2
@@ -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/");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user