Merge branch 'master' of https://git.mcnd.ca/mcndave/lean
This commit is contained in:
commit
0ad57c87df
16 files changed
+314
-88
No files matched your search
@@ -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, ],
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@ use Storage\Cookie,
|
||||
Storage\Session,
|
||||
Storage\SessionMiddleware;
|
||||
|
||||
$dir = dirname(__DIR__, 2);
|
||||
|
||||
return [
|
||||
'lean.default' => [
|
||||
'picea' => [
|
||||
@@ -29,11 +31,18 @@ return [
|
||||
'order' => 10,
|
||||
],
|
||||
[
|
||||
'path' => getenv("PROJECT_PATH") . implode(DIRECTORY_SEPARATOR, [ "", "vendor", "mcnd" , "lean" , "view" ]),
|
||||
'path' => implode(DIRECTORY_SEPARATOR, [ $dir, "view", '' ]),
|
||||
'order' => 99,
|
||||
],
|
||||
],
|
||||
|
||||
'asset' => [
|
||||
[
|
||||
'path' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), "asset", '' ]),
|
||||
'order' => 10
|
||||
]
|
||||
],
|
||||
|
||||
'extensions' => [],
|
||||
],
|
||||
|
||||
@@ -83,11 +92,11 @@ return [
|
||||
$gitdir = getenv("PROJECT_PATH") . DIRECTORY_SEPARATOR . ".git" . DIRECTORY_SEPARATOR;
|
||||
|
||||
if ( file_exists($gitdir . "HEAD") ) {
|
||||
if (false !== ($currentBranch = file_get_contents($gitdir . "HEAD"))) {
|
||||
if (false !== ($currentBranch = file_get_contents($gitdir . "HEAD"))) {
|
||||
$file = explode(": ", $currentBranch)[1];
|
||||
$path = $gitdir . str_replace("/", DIRECTORY_SEPARATOR, trim($file, " \t\n\r"));
|
||||
|
||||
return trim(file_get_contents($path), " \t\n\r");
|
||||
return file_exists($path) ? trim(file_get_contents($path), " \t\n\r") : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,23 +2,47 @@
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use Picea\{
|
||||
Language\LanguageRegistration,
|
||||
Caching\Cache,
|
||||
Caching\Opcache,
|
||||
Compiler,
|
||||
Compiler\Context,
|
||||
Compiler\BaseContext,
|
||||
FileFetcher,
|
||||
Method\Request};
|
||||
|
||||
use Picea\Extension\{ LanguageHandlerInterface, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
|
||||
|
||||
use Picea\{ 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 };
|
||||
|
||||
return [
|
||||
Picea::class => function($c) {
|
||||
return new Picea($c->get(Context::class), $c->get(Cache::class), $c->get(Compiler::class), null, $c->get(FileFetcher::class), null, getenv("DEBUG"));
|
||||
Picea\Picea::class => function($c) {
|
||||
return new Picea\Picea($c->get(Context::class), $c->get(Cache::class), $c->get(Compiler::class), null, $c->get(FileFetcher::class), null, getenv("DEBUG"));
|
||||
},
|
||||
|
||||
Context::class => function($c) {
|
||||
return new BaseContext( $c->get(Lean\Lean::class)->getPiceaContext() );
|
||||
return new BaseContext($c->get(Lean\Lean::class)->getPiceaContext());
|
||||
},
|
||||
|
||||
Compiler::class => function($c) {
|
||||
return new Compiler(new class(array_merge([
|
||||
Ui::class => autowire(Ui::class),
|
||||
|
||||
Compiler::class => autowire(Compiler::class),
|
||||
|
||||
Request::class => autowire(Request::class),
|
||||
|
||||
Method\Form::class => autowire(Method\Form::class),
|
||||
|
||||
Method\Pagination::class => autowire(Method\Pagination::class),
|
||||
|
||||
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandlerInterface::class)),
|
||||
|
||||
LanguageHandlerInterface::class => autowire(\Lean\LanguageHandler::class),
|
||||
|
||||
LanguageRegistration::class => create(\Lean\PiceaDefaultRegistration::class)->constructor(get('picea.extensions'), [], [], get(Ui::class), null),
|
||||
|
||||
'picea.extensions' => function(\Psr\Container\ContainerInterface $c) {
|
||||
return array_merge([
|
||||
$c->get(LanguageExtension::class),
|
||||
$c->get(TitleExtension::class),
|
||||
$c->get(NumberExtension::class),
|
||||
@@ -27,38 +51,8 @@ return [
|
||||
$c->get(Method\Pagination::class),
|
||||
$c->get(Request::class),
|
||||
], class_exists(\Taxus\Picea\Extension::class) ? [ $c->get(\Taxus\Picea\Extension::class) ] : [],
|
||||
array_map(fn($class) => $c->get($class), $c->get(Lean\Lean::class)->getPiceaExtensions() ))) extends DefaultRegistrations {
|
||||
|
||||
public function registerAll(Compiler $compiler) : void
|
||||
{
|
||||
parent::registerAll($compiler);
|
||||
( new Ui() )->registerFormExtension($compiler);
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
|
||||
Request::class => autowire(Request::class),
|
||||
|
||||
Method\Form::class => autowire(Method\Form::class),
|
||||
|
||||
Method\Pagination::class => autowire(Method\Pagination::class),
|
||||
|
||||
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandler::class)),
|
||||
|
||||
LanguageHandler::class => function($c) {
|
||||
return new class( $c->get(Tell\I18n::class) ) implements LanguageHandler {
|
||||
public Tell\I18n $tell;
|
||||
|
||||
public function __construct(Tell\I18n $tell) {
|
||||
$this->tell = $tell;
|
||||
}
|
||||
|
||||
public function languageFromKey(string $key, array $variables = []) #: array|string
|
||||
{
|
||||
return $this->tell->fromKey($key, $variables) ?: "";
|
||||
}
|
||||
};
|
||||
array_map(fn($class) => $c->get($class), $c->get(Lean\Lean::class)->getPiceaExtensions())
|
||||
);
|
||||
},
|
||||
|
||||
TitleExtension::class => autowire(TitleExtension::class),
|
||||
|
||||
Reference in new issue
Block a user