- Merging ulmus-auth branch into master

This commit is contained in:
mcndave committed 2026-10-19 16:18:01 -04:00
commit ca4b5c98a1
14 files changed
+123 -54

No files matched your search

@@ -39,7 +39,7 @@ class NotFoundDecorator implements NotFoundDecoratorInterface
public function throw404(ServerRequestInterface $request) : ResponseInterface
{
return $this->checkAssetTrigger($request) ?: $this->httpFactory->createHtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404);
return $this->checkAssetTrigger($request) ?: $this->container->get('error.404');
}
protected function checkAssetTrigger(ServerRequestInterface $request) : false|ResponseInterface
+10 -1
View File
@@ -7,7 +7,6 @@ use Lean\Factory\HttpFactory;
use Notes\Attribute\Ignore;
use Notes\Route\Attribute\Object\Route;
use Notes\Security\Attribute\Security;
use Picea, Picea\Ui\Method\FormContext;
use Picea\Ui\Method\FormContextInterface;
use TheBugs\Email\MailerInterface;
use Storage\{ Cookie, Session };
@@ -210,6 +209,16 @@ trait ControllerTrait {
return $this->picea->compiler->getExtensionFromToken('route')->buildRouteUrl($name, $parameters);
}
#[Ignore]
public function form(FormInterface $form, ? FormContextInterface $formContext = null) : Picea\Ui\Method\FormHandler
{
if (! $this->picea ) {
throw new \Exception("A picea object must be provided on class initialization to use this method.");
}
return $this->picea->compiler->getExtensionInstanceOf(Picea\Ui\Method\Form::class)->formClass($form, $formContext);
}
#[Ignore]
public function json($data, int $flags = 0) : string
{
+1 -5
View File
@@ -2,9 +2,6 @@
namespace Lean\Factory;
use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, RedirectResponse, TextResponse};
use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse };
use Laminas\Diactoros\Response;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\StreamInterface;
@@ -20,6 +17,5 @@ interface HttpFactoryInterface
public static function createDownloadableResponse(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface;
public static function createImageResponse(string $data, int $code = 200, array $headers = []) : ResponseInterface;
public static function createFileDownloadResponse(string $path, int $code = 200, array $headers = []) : ResponseInterface;
public static function createStream(string $content) : StreamInterface;
}
}
+17 -11
View File
@@ -11,13 +11,16 @@ use League\Route\Strategy\ApplicationStrategy;
use Psr\Http\Message\ServerRequestInterface;
use Tell\I18n;
use Ulmus\Container\AdapterProxy;
use Laminas\Diactoros\ServerRequestFactory,
Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
use Ulmus\Ulmus;
class Kernel
{
class Kernel {
protected Container $container;
protected string $locale;
@@ -34,10 +37,12 @@ class Kernel
public function __construct(
public string $projectPath
)
{
) {
# Still not sure about adding a folder check each call just to add a basic project setup error ...
# File::assertFolderExists($this->projectPath);
define('IS_CLI', php_sapi_name() === 'cli' OR defined('STDIN'));
$this->setEnvironment();
$this->initializeEngine();
$this->setupContainer();
@@ -74,12 +79,14 @@ class Kernel
// Paths and directories
foreach($this->paths as $name => $envkey) {
if (!getenv($name)) {
if ( ! getenv($name) ) {
$path = getenv("PROJECT_PATH") . DIRECTORY_SEPARATOR . getenv($envkey);
if (getenv('DEBUG') && ! file_exists($path)) {
if (false === mkdir($path, 0755, true)) {
throw new \Exception(sprintf("Folder '%s' could not be created", $path));
if (false === @mkdir($path, 0755, true)) {
if (! IS_CLI) {
throw new \Exception(sprintf("Folder '%s' could not be created", $path));
}
}
}
@@ -96,7 +103,7 @@ class Kernel
setlocale(LC_ALL, $this->locale = getenv("DEFAULT_LOCAL"));
setlocale(LC_TIME, getenv("DEFAULT_TIME"), getenv("DEFAULT_TIME_FALLBACK"));
if (class_exists('Locale')) {
if ( class_exists('Locale') ) {
\Locale::setDefault($this->locale);
}
@@ -122,8 +129,7 @@ class Kernel
if (getenv("APP_ENV") === "prod") {
if (getenv("CACHE_PATH")) {
# check if ACPU is there first,
# $containerBuilder->enableDefinitionCache(); # Do not work .. ?
# check if ACPU is there first, $containerBuilder->enableDefinitionCache();
$containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/");
# No proxies yet... $containerBuilder->writeProxiesToFile(true, getenv("CACHE_PATH") . "/di/");
@@ -190,4 +196,4 @@ class Kernel
return $this;
}
}
};
+5
View File
@@ -44,6 +44,11 @@ class Routing {
$container->set(ServerRequestInterface::class, $request);
# Decoding arguments received from the router
foreach($arguments as &$arg) {
$arg = urldecode($arg);
}
return $this->response ?? $object->$method($request, $arguments);
});
}