Compare commits

...

5 Commits

Author SHA1 Message Date
Dave Mc Nicoll
01d48463b3 - Merged with master done 2026-05-21 15:18:50 +00:00
Dave Mc Nicoll
abe94e498f - Fixed conflicts 2026-05-21 15:18:49 +00:00
Dev
adfd619c5f - Fixed default view order to 1000 2026-05-21 15:18:04 +00:00
16ee06593c - Added createStream methods and fixed multiple errors views 2026-05-21 15:18:03 +00:00
5bb5e8ce61 - Added MethodNotAllowed interface 2026-05-21 15:16:58 +00:00
5 changed files with 53 additions and 23 deletions

View File

@ -2,12 +2,14 @@
use Lean\Factory\HttpFactoryInterface; use Lean\Factory\HttpFactoryInterface;
use Ulmus\User\{ use Ulmus\User\{Authorize\HeaderAuthentication,
Authorize\HeaderAuthentication, Authorize\PostRequestAuthentication,
Entity, Entity,
Lib\Authenticate, Lib\Authorize, Lib\Authenticate,
Middleware\AuthenticationMiddleware, Middleware\HeaderAuthenticationMiddleware, Middleware\PostRequestAuthenticationMiddleware, Lib\Authorize,
}; Middleware\AuthenticationMiddleware,
Middleware\HeaderAuthenticationMiddleware,
Middleware\PostRequestAuthenticationMiddleware,
Authorize\PostRequestAuthentication};
use Picea\Picea; use Picea\Picea;
use Storage\{ Cookie, Session }; use Storage\{ Cookie, Session };
@ -15,6 +17,7 @@ use Psr\Container\ContainerInterface;
use function DI\{get, autowire, create}; use function DI\{get, autowire, create};
return [ return [
Authorize::class => create(Authorize::class)->constructor(get(Entity\UserInterface::class), get(Session::class), get(Cookie::class), get('authentication.method')), Authorize::class => create(Authorize::class)->constructor(get(Entity\UserInterface::class), get(Session::class), get(Cookie::class), get('authentication.method')),
@ -35,9 +38,9 @@ return [
'authorize.error' => function(ContainerInterface $c) { 'authorize.error' => function(ContainerInterface $c) {
return function(array $errorData) use ($c) { return function(array $errorData) use ($c) {
return $c->get(HttpFactoryInterface::class)::createJsonResponse($errorData + [ return $c->get(HttpFactoryInterface::class)::createJsonResponse($errorData + [
'api.error' => "Authorization failed", 'api.error' => "Authorization failed",
'api.datetime' => (new \DateTime)->format(\DateTime::ATOM), 'api.datetime' => (new \DateTime)->format(\DateTime::ATOM),
], 403); ], 403);
}; };
}, },

View File

@ -1,15 +1,13 @@
<?php <?php
use Psr\Container\ContainerInterface;
use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator, MethodNotAllowedInterface, }; use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator, MethodNotAllowedInterface, };
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\ServerRequestInterface;
use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter }; use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter };
use Lean\Factory\{ HttpFactory, HttpFactoryInterface }; use Lean\Factory\{ HttpFactory, HttpFactoryInterface };
use Picea\Picea; use Picea\Picea;
use function DI\autowire, DI\create, DI\get; use function DI\{ autowire, create, get };
return [ return [
ServerRequestInterface::class => function ($c) { ServerRequestInterface::class => function ($c) {
@ -20,6 +18,10 @@ return [
EmitterInterface::class => create(SapiEmitter::class), EmitterInterface::class => create(SapiEmitter::class),
ThrowableHandlerInterface::class => autowire(ThrowableHandler::class),
NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class),
# MethodNotAllowedInterface::class => autowire(MethodNotAllowedDecorator::class),
HttpFactoryInterface::class => create(HttpFactory::class), HttpFactoryInterface::class => create(HttpFactory::class),
'error.401' => function(ContainerInterface $c, Picea $picea) { 'error.401' => function(ContainerInterface $c, Picea $picea) {
@ -32,9 +34,5 @@ return [
'error.500' => function(ContainerInterface $c, Picea $picea) { 'error.500' => function(ContainerInterface $c, Picea $picea) {
return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/500", []), 500); return $c->get(HttpFactoryInterface::class)::createHtmlResponse($picea->renderHtml("lean/error/500", []), 500);
}, }
ThrowableHandlerInterface::class => autowire(ThrowableHandler::class),
NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class),
# MethodNotAllowedInterface::class => autowire(MethodNotAllowedDecorator::class),
]; ];

View File

@ -39,4 +39,37 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy {
{ {
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception); return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
} }
/*
<<<<<<< HEAD
public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface
{
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
=======
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{
if (php_sapi_name() !== 'cli' and ! defined('STDIN')) {
return $this->throw404($request);
}
return $handler->handle($request);;
}
public function throw404(ServerRequestInterface $request) : ResponseInterface
{
if ( getenv('DEBUG') && $this->di->has(\Picea\Asset\Asset::class) ) {
$params = $request->getServerParams();
$scpName = basename(explode('?', $params['REQUEST_URI'] ?? "", 2)[0]);
list(, $ext) = array_pad(explode('.', $scpName), 2, null);
if ($ext && in_array($ext, ApplicationStrategy::ASSET_TRIGGER_UPDATE)) {
$this->di->get(\Picea\Asset\Asset::class)->launchInstall();
}
}
return $this->di->get('error.404');
}
};
>>>>>>> af8b686 (- WIP on ulmus-user mechanics updates)
}*/
} }

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 40 KiB

View File

@ -10,7 +10,7 @@
{% if $messageList %} {% if $messageList %}
<div class="message-wrapper">{% php <div class="message-wrapper">{% php
foreach($messageList as $name => $context) { foreach($messageList as $name => $context) {
foreach($context->messages ?? [] as $message) { foreach($context->formContextMessages ?? [] as $message) {
echo $message->render(); echo $message->render();
} }
} }