- WIP on ulmus-user mechanics updates
This commit is contained in:
1 parent
064d94d32a
commit
50b17ec8b6
8 files changed
+84
-22
No files matched your search
@@ -37,5 +37,36 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy {
|
||||
public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface
|
||||
{
|
||||
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
|
||||
|
||||
}
|
||||
/*=======
|
||||
public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface
|
||||
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)*/
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Notes\Route\Attribute\Object\Route;
|
||||
use Notes\Security\Attribute\Security;
|
||||
use Picea, Picea\Ui\Method\FormContext;
|
||||
use Picea\Ui\Method\FormContextInterface;
|
||||
use Picea\Ui\Method\FormInterface;
|
||||
use TheBugs\Email\MailerInterface;
|
||||
use Storage\{ Cookie, Session };
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
@@ -210,6 +211,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
|
||||
{
|
||||
|
||||
+9
-5
@@ -24,7 +24,7 @@ class Kernel
|
||||
|
||||
public array $paths = [];
|
||||
|
||||
public int $errorReportingDev = -1;
|
||||
public int $errorReportingDev = -1 & ~E_USER_DEPRECATED & ~E_DEPRECATED ;
|
||||
|
||||
public int $errorReportingProd = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED /*& ~E_NOTICE*/;
|
||||
|
||||
@@ -34,10 +34,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();
|
||||
@@ -78,8 +80,10 @@ class Kernel
|
||||
$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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user