Compare commits
9 Commits
1c2ce07179
...
dac7acde87
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dac7acde87 | ||
|
|
b16b4803c5 | ||
|
|
d54d78ccc5 | ||
| 9ff4d6c44d | |||
| a4b02607f3 | |||
| d74c916558 | |||
|
|
ca388e8a52 | ||
| b12fc65ea9 | |||
| 4b76a387fe |
@ -3,19 +3,15 @@
|
|||||||
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\Authenticate, Lib\Authorize,
|
||||||
Lib\Authorize,
|
Middleware\AuthenticationMiddleware, Middleware\HeaderAuthenticationMiddleware, Middleware\PostRequestAuthenticationMiddleware,
|
||||||
Middleware\AuthenticationMiddleware,
|
|
||||||
Middleware\HeaderAuthenticationMiddleware,
|
|
||||||
Middleware\PostRequestAuthenticationMiddleware,
|
|
||||||
Authorize\PostRequestAuthentication
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use Picea\Picea;
|
||||||
use Storage\{ Cookie, Session };
|
use Storage\{ Cookie, Session };
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
use Picea\Picea;
|
|
||||||
|
|
||||||
use function DI\{get, autowire, create};
|
use function DI\{get, autowire, create};
|
||||||
|
|
||||||
@ -39,7 +35,6 @@ 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);
|
||||||
|
|||||||
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use Psr\Container\ContainerInterface;
|
use Psr\Container\ContainerInterface;
|
||||||
|
|
||||||
|
use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator, MethodNotAllowedInterface, };
|
||||||
|
|
||||||
use Lean\ApplicationStrategy\{ ThrowableHandler, ThrowableHandlerInterface, NotFoundDecoratorInterface, NotFoundDecorator };
|
|
||||||
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 };
|
||||||
@ -36,4 +36,5 @@ return [
|
|||||||
|
|
||||||
ThrowableHandlerInterface::class => autowire(ThrowableHandler::class),
|
ThrowableHandlerInterface::class => autowire(ThrowableHandler::class),
|
||||||
NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class),
|
NotFoundDecoratorInterface::class => autowire(NotFoundDecorator::class),
|
||||||
|
# MethodNotAllowedInterface::class => autowire(MethodNotAllowedDecorator::class),
|
||||||
];
|
];
|
||||||
|
|||||||
@ -59,7 +59,7 @@ return [
|
|||||||
$router = $container->get(Router::class);
|
$router = $container->get(Router::class);
|
||||||
|
|
||||||
foreach([ 'routes.middlewares', 'app.middlewares' ] as $key) {
|
foreach([ 'routes.middlewares', 'app.middlewares' ] as $key) {
|
||||||
if ( $container->has($key) ) {
|
if ($container->has($key)) {
|
||||||
foreach ($container->get($key) as $i => $middleware) {
|
foreach ($container->get($key) as $i => $middleware) {
|
||||||
if ($container->has($middleware)) {
|
if ($container->has($middleware)) {
|
||||||
$router->middleware($container->get($middleware));
|
$router->middleware($container->get($middleware));
|
||||||
@ -68,7 +68,8 @@ return [
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$router->addPatternMatcher('email', '[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+');
|
$router->addPatternMatcher('email', '[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n/]+');
|
||||||
|
$router->addPatternMatcher('ids', '\b\d[\d,]*\b');
|
||||||
|
|
||||||
$routing = $container->get(Lean\Routing::class);
|
$routing = $container->get(Lean\Routing::class);
|
||||||
$routing->registerRoute($container, getenv('URL_BASE'));
|
$routing->registerRoute($container, getenv('URL_BASE'));
|
||||||
|
|||||||
@ -5,6 +5,15 @@
|
|||||||
"week": "week"
|
"week": "week"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"interval": {
|
||||||
|
"years": "{$years} year(s)",
|
||||||
|
"months": "{$months} month(s)",
|
||||||
|
"days": "{$days} day(s)",
|
||||||
|
"hours": "{$hours} hour(s)",
|
||||||
|
"minutes": "{$minutes} minutes(s)",
|
||||||
|
"seconds": "{$seconds} second(s)"
|
||||||
|
},
|
||||||
|
|
||||||
"month": {
|
"month": {
|
||||||
"list": [
|
"list": [
|
||||||
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Décember"
|
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Décember"
|
||||||
|
|||||||
@ -4,6 +4,15 @@
|
|||||||
"week": "semaine"
|
"week": "semaine"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"interval": {
|
||||||
|
"years": "{$years} années(s)",
|
||||||
|
"months": "{$months} mois",
|
||||||
|
"days": "{$days} jour(s)",
|
||||||
|
"hours": "{$hours} heure(s)",
|
||||||
|
"minutes": "{$minutes} minutes(s)",
|
||||||
|
"seconds": "{$seconds} seconde(s)"
|
||||||
|
},
|
||||||
|
|
||||||
"month": {
|
"month": {
|
||||||
"list": [
|
"list": [
|
||||||
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
||||||
|
|||||||
@ -8,17 +8,27 @@
|
|||||||
],
|
],
|
||||||
"minimum-stability": "dev",
|
"minimum-stability": "dev",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^8.2",
|
"php": "^8.4",
|
||||||
"ext-apcu": "*",
|
"ext-apcu": "*",
|
||||||
|
"ext-sodium": "*",
|
||||||
|
"ext-bcmath": "*",
|
||||||
"ext-json": "*",
|
"ext-json": "*",
|
||||||
|
"ext-readline": "*",
|
||||||
"league/route": "^5.0.0-dev",
|
"league/route": "^5.0.0-dev",
|
||||||
"laminas/laminas-diactoros": "2.24.x-dev",
|
"laminas/laminas-diactoros": "2.24.x-dev",
|
||||||
"laminas/laminas-httphandlerrunner": "2.5.x-dev",
|
"laminas/laminas-httphandlerrunner": "2.5.x-dev",
|
||||||
"vlucas/phpdotenv": "^3.4@dev",
|
"vlucas/phpdotenv": "^3.4@dev",
|
||||||
"middlewares/whoops": "dev-master",
|
"middlewares/whoops": "dev-master",
|
||||||
"ralouphie/getallheaders": "dev-master",
|
"ralouphie/getallheaders": "3.x",
|
||||||
|
"guzzlehttp/guzzle": "7.9.x-dev",
|
||||||
|
"symfony/mailer": "6.3.x-dev",
|
||||||
|
"league/oauth2-client": "dev-master",
|
||||||
|
"php-di/php-di": "dev-master",
|
||||||
|
"league/commonmark": "^2.7@dev",
|
||||||
|
"assets-package/ace": "dev-master",
|
||||||
"mcnd/dump": "dev-master",
|
"mcnd/dump": "dev-master",
|
||||||
"mcnd/storage": "dev-master",
|
"mcnd/storage": "dev-master",
|
||||||
|
"mcnd/cli": "dev-master",
|
||||||
"mcnd/event": "dev-master",
|
"mcnd/event": "dev-master",
|
||||||
"mcnd/ulmus": "dev-master",
|
"mcnd/ulmus": "dev-master",
|
||||||
"mcnd/ulmus-api": "dev-master",
|
"mcnd/ulmus-api": "dev-master",
|
||||||
@ -27,6 +37,7 @@
|
|||||||
"mcnd/picea-ui": "dev-master",
|
"mcnd/picea-ui": "dev-master",
|
||||||
"mcnd/picea-asset": "dev-master",
|
"mcnd/picea-asset": "dev-master",
|
||||||
"mcnd/cronard": "dev-master",
|
"mcnd/cronard": "dev-master",
|
||||||
|
"mcnd/lean-api": "dev-master",
|
||||||
"mcnd/lean-console": "dev-master",
|
"mcnd/lean-console": "dev-master",
|
||||||
"mcnd/kash": "dev-master",
|
"mcnd/kash": "dev-master",
|
||||||
"mcnd/taxus": "dev-master",
|
"mcnd/taxus": "dev-master",
|
||||||
@ -39,6 +50,10 @@
|
|||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://git.mcnd.ca/mcndave/cronard.git"
|
"url": "https://git.mcnd.ca/mcndave/cronard.git"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "https://git.mcnd.ca/mcndave/cli.git"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://git.mcnd.ca/mcndave/dump.git"
|
"url": "https://git.mcnd.ca/mcndave/dump.git"
|
||||||
@ -51,6 +66,10 @@
|
|||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://git.mcnd.ca/mcndave/lean.git"
|
"url": "https://git.mcnd.ca/mcndave/lean.git"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "https://git.mcnd.ca/mcndave/lean-api.git"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://git.mcnd.ca/mcndave/lean-console.git"
|
"url": "https://git.mcnd.ca/mcndave/lean-console.git"
|
||||||
@ -118,6 +137,10 @@
|
|||||||
{
|
{
|
||||||
"type": "vcs",
|
"type": "vcs",
|
||||||
"url": "https://git.mcnd.ca/mcndave/negundo-client.git"
|
"url": "https://git.mcnd.ca/mcndave/negundo-client.git"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "vcs",
|
||||||
|
"url": "https://git.mcnd.ca/assets-package/ace.git"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"autoload": {
|
"autoload": {
|
||||||
@ -136,6 +159,7 @@
|
|||||||
"extra" : {
|
"extra" : {
|
||||||
"lean" : {
|
"lean" : {
|
||||||
"autoload": {
|
"autoload": {
|
||||||
|
"order": 1000,
|
||||||
"definitions" : [
|
"definitions" : [
|
||||||
"meta/definitions/definitions.php",
|
"meta/definitions/definitions.php",
|
||||||
"meta/definitions/storage.php",
|
"meta/definitions/storage.php",
|
||||||
|
|||||||
@ -10,7 +10,7 @@ return [
|
|||||||
],
|
],
|
||||||
|
|
||||||
'keys' => (function() {
|
'keys' => (function() {
|
||||||
return explode(',', getenv('KEYS') ?? "") ;
|
return explode(',', getenvonce('KEYS') ?? "") ;
|
||||||
})(),
|
})(),
|
||||||
|
|
||||||
'meta' => [
|
'meta' => [
|
||||||
|
|||||||
@ -7,6 +7,10 @@ use function DI\{ autowire, add, create, get };
|
|||||||
$dir = dirname(__DIR__, 2);
|
$dir = dirname(__DIR__, 2);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
|
\%NAMESPACE%\Factory\FormFactoryInterface::class => autowire(\%NAMESPACE%\Factory\FormFactory::class),
|
||||||
|
\Lean\Api\Factory\MessageFactoryInterface::class => autowire(\%NAMESPACE%\Lib\Message::class),
|
||||||
|
|
||||||
|
|
||||||
'%APPKEY%' => [
|
'%APPKEY%' => [
|
||||||
'picea' => [
|
'picea' => [
|
||||||
'context' => "%ESCAPED_NAMESPACE%\\View",
|
'context' => "%ESCAPED_NAMESPACE%\\View",
|
||||||
|
|||||||
46
skeleton/src/Factory/FormFactory.php
Normal file
46
skeleton/src/Factory/FormFactory.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace %NAMESPACE%\Factory;
|
||||||
|
|
||||||
|
use Lean\Api\Factory\MessageFactoryInterface;
|
||||||
|
use Lean\LanguageHandler;
|
||||||
|
use Picea\Ui\Method\FormContextInterface;
|
||||||
|
use Picea\Ui\Method\FormInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Storage\Session;
|
||||||
|
use Ulmus\Entity\EntityInterface;
|
||||||
|
use Ulmus\User\Entity\UserInterface;
|
||||||
|
use Ulmus\User\Lib\Authenticate;
|
||||||
|
|
||||||
|
class FormFactory implements FormFactoryInterface
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
public function __construct(
|
||||||
|
protected ServerRequestInterface $request,
|
||||||
|
protected Authenticate $authenticate,
|
||||||
|
protected Session $session,
|
||||||
|
protected LanguageHandler $languageHandler,
|
||||||
|
protected MessageFactoryInterface $messageFactory,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function save(EntityInterface $entity): FormInterface
|
||||||
|
{
|
||||||
|
return new Form\Save($this->languageHandler, $this->messageFactory, $entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function saveContext(? ServerRequestInterface $request = null, ? string $formName = null): FormContextInterface
|
||||||
|
{
|
||||||
|
return new Form\SaveContext($request ?: $this->request, $formName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function delete(EntityInterface $entity): FormInterface
|
||||||
|
{
|
||||||
|
return new Form\Delete($this->languageHandler, $this->messageFactory, $entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function deleteContext(?ServerRequestInterface $request = null, ?string $formName = null): FormContextInterface
|
||||||
|
{
|
||||||
|
return new Lib\FormContext($request, $formName);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}
|
||||||
25
skeleton/src/Factory/FormFactoryInterface.php
Normal file
25
skeleton/src/Factory/FormFactoryInterface.php
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace %NAMESPACE%\Factory;
|
||||||
|
|
||||||
|
use Lean\Api\Factory\MessageFactoryInterface;
|
||||||
|
use Psr\Http\Message\ServerRequestInterface;
|
||||||
|
use Picea\Ui\Method\{ FormInterface, FormContextInterface };
|
||||||
|
use Storage\Session;
|
||||||
|
use Lean\LanguageHandler;
|
||||||
|
use Ulmus\Entity\EntityInterface;
|
||||||
|
use Ulmus\User\Entity\UserInterface;
|
||||||
|
use Ulmus\User\Lib\Authenticate;
|
||||||
|
|
||||||
|
interface FormFactoryInterface
|
||||||
|
{
|
||||||
|
/* public function __construct(ServerRequestInterface $request, Authenticate $authenticate, Session $session, LanguageHandler $languageHandler, MessageFactoryInterface $messageFactory,);
|
||||||
|
|
||||||
|
public function save(EntityInterface $entity): FormInterface;
|
||||||
|
|
||||||
|
public function saveContext(?ServerRequestInterface $request = null, ?string $formName = null): FormContextInterface;
|
||||||
|
|
||||||
|
public function delete(EntityInterface $entity): FormInterface;
|
||||||
|
|
||||||
|
public function deleteContext(?ServerRequestInterface $request = null, ?string $formName = null): FormContextInterface;*/
|
||||||
|
}
|
||||||
28
skeleton/src/Lib/ApiTrait.php
Normal file
28
skeleton/src/Lib/ApiTrait.php
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace %NAMESPACE%\Lib;
|
||||||
|
|
||||||
|
use Picea\Picea;
|
||||||
|
use Storage\Session;
|
||||||
|
use Mcnd\Event\EventManager;
|
||||||
|
use Notes\{ Attribute\Ignore, Route\Attribute\Object\Route, Security\Attribute\Security };
|
||||||
|
use Ulmus\User\Entity\{ User, UserInterface };
|
||||||
|
|
||||||
|
use %NAMESPACE%\{ Entity, Lib, Form, Factory };
|
||||||
|
|
||||||
|
#[Security(locked: false)]
|
||||||
|
#[Route(base: "/api", method: [ "GET", "POST", "PUT", "PATCH", "DELETE", ])]
|
||||||
|
trait ApiTrait {
|
||||||
|
use \Lean\ControllerTrait, \Lean\Api\LeanApiTrait {
|
||||||
|
\Lean\Api\LeanApiTrait::renderMarkdown insteadof \Lean\ControllerTrait;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Ignore]
|
||||||
|
public UserInterface $user;
|
||||||
|
|
||||||
|
#[Ignore]
|
||||||
|
protected EventManager $eventManager;
|
||||||
|
|
||||||
|
#[Ignore]
|
||||||
|
protected Factory\FormFactoryInterface $formFactory;
|
||||||
|
}
|
||||||
@ -23,19 +23,4 @@ trait ControllerTrait {
|
|||||||
|
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
protected EventManager $eventManager;
|
protected EventManager $eventManager;
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function __construct(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
|
|
||||||
$this->initializeController($picea, $session, $user, $breadcrumb, $eventManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Ignore]
|
|
||||||
public function initializeController(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
|
|
||||||
$this->picea = $picea;
|
|
||||||
$this->session = $session;
|
|
||||||
$this->eventManager = $eventManager;
|
|
||||||
$this->breadcrumb = $breadcrumb;
|
|
||||||
$this->user = $user;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -2,9 +2,10 @@
|
|||||||
|
|
||||||
namespace %NAMESPACE%\Lib;
|
namespace %NAMESPACE%\Lib;
|
||||||
|
|
||||||
|
use Lean\Api\Factory\MessageFactoryInterface;
|
||||||
use Picea\Ui\Method\FormMessage;
|
use Picea\Ui\Method\FormMessage;
|
||||||
|
|
||||||
class Message implements FormMessage {
|
class Message implements FormMessage, MessageFactoryInterface {
|
||||||
|
|
||||||
const MESSAGE_TYPE = [
|
const MESSAGE_TYPE = [
|
||||||
'success' => [
|
'success' => [
|
||||||
@ -34,7 +35,7 @@ class Message implements FormMessage {
|
|||||||
|
|
||||||
public ? string $header = null;
|
public ? string $header = null;
|
||||||
|
|
||||||
public function __construct(string $message, string $type = "error", ? string $header = null, ? string $class = null)
|
public function __construct(string $message = "", string $type = "error", ? string $header = null, ? string $class = null)
|
||||||
{
|
{
|
||||||
$this->message = $message;
|
$this->message = $message;
|
||||||
|
|
||||||
@ -86,18 +87,33 @@ class Message implements FormMessage {
|
|||||||
return $this->type === "error";
|
return $this->type === "error";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateSuccess(string $message, ? string $header = null, ? string $class = null) : self
|
public static function generateSuccess(string $message, ? string $header = null, ? string $class = null) : MessageFactoryInterface
|
||||||
{
|
{
|
||||||
return new static($message, 'success', $header, $class);
|
return new static($message, 'success', $header, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateError(string $message, ? string $header = null, ? string $class = null) : self
|
public static function generateError(string $message, ? string $header = null, ? string $class = null) : MessageFactoryInterface
|
||||||
{
|
{
|
||||||
return new static($message, 'error', $header, $class);
|
return new static($message, 'error', $header, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function generateWarning(string $message, ? string $header = null, ? string $class = null) : self
|
public static function generateWarning(string $message, ? string $header = null, ? string $class = null) : MessageFactoryInterface
|
||||||
{
|
{
|
||||||
return new static($message, 'warning', $header, $class);
|
return new static($message, 'warning', $header, $class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function generateInformation(string $message, ?string $header = null, ?string $class = null): MessageFactoryInterface
|
||||||
|
{
|
||||||
|
return new static($message, 'information', $header, $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function generateDebug(string $message, ?string $header = null, ?string $class = null): MessageFactoryInterface
|
||||||
|
{
|
||||||
|
return new static($message, 'debug', $header, $class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function generateTrace(string $message, ?string $header = null, ?string $class = null): MessageFactoryInterface
|
||||||
|
{
|
||||||
|
return new static($message, 'trace', $header, $class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,8 +2,10 @@
|
|||||||
|
|
||||||
namespace Lean;
|
namespace Lean;
|
||||||
|
|
||||||
|
use League\Route\Http\Exception\MethodNotAllowedException;
|
||||||
use League\Route\Strategy;
|
use League\Route\Strategy;
|
||||||
use League\Route\Http\Exception\NotFoundException;
|
use League\Route\Http\Exception\NotFoundException;
|
||||||
|
use Lean\ApplicationStrategy\MethodNotAllowedInterface;
|
||||||
use Lean\ApplicationStrategy\NotFoundDecoratorInterface;
|
use Lean\ApplicationStrategy\NotFoundDecoratorInterface;
|
||||||
use Lean\ApplicationStrategy\ThrowableHandlerInterface;
|
use Lean\ApplicationStrategy\ThrowableHandlerInterface;
|
||||||
use Lean\Factory\HttpFactoryInterface;
|
use Lean\Factory\HttpFactoryInterface;
|
||||||
@ -32,4 +34,9 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy {
|
|||||||
return $this->getContainer()->get(ThrowableHandlerInterface::class);
|
return $this->getContainer()->get(ThrowableHandlerInterface::class);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getMethodNotAllowedDecorator(MethodNotAllowedException $exception): MiddlewareInterface
|
||||||
|
{
|
||||||
|
return $this->getContainer()->has(MethodNotAllowedInterface::class) ? $this->getContainer()->get(MethodNotAllowedInterface::class) : parent::getMethodNotAllowedDecorator($exception);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
10
src/ApplicationStrategy/MethodNotAllowedInterface.php
Normal file
10
src/ApplicationStrategy/MethodNotAllowedInterface.php
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Lean\ApplicationStrategy;
|
||||||
|
|
||||||
|
use Psr\Http\Server\MiddlewareInterface;
|
||||||
|
|
||||||
|
interface MethodNotAllowedInterface extends MiddlewareInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@ -39,7 +39,7 @@ class NotFoundDecorator implements NotFoundDecoratorInterface
|
|||||||
|
|
||||||
public function throw404(ServerRequestInterface $request) : ResponseInterface
|
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
|
protected function checkAssetTrigger(ServerRequestInterface $request) : false|ResponseInterface
|
||||||
|
|||||||
@ -102,7 +102,7 @@ class Composer
|
|||||||
throw new \UnexpectedValueException("Composer file 'composer.json' could not be found within your project's root folder.");
|
throw new \UnexpectedValueException("Composer file 'composer.json' could not be found within your project's root folder.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return $content ??= file_exists($path) ? json_decode(file_get_contents($path), true) : false;
|
return $content ??= file_exists($path) ? json_decode(file_get_contents($path), true, 512, \JSON_THROW_ON_ERROR) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function getNamespaceFromAutoload(Event $event) : ? string
|
protected static function getNamespaceFromAutoload(Event $event) : ? string
|
||||||
@ -125,7 +125,7 @@ class Composer
|
|||||||
|
|
||||||
$event->getIO()->writeError("Your composer file do not seem to contains a valid psr-4 project pointing to the src folder.");
|
$event->getIO()->writeError("Your composer file do not seem to contains a valid psr-4 project pointing to the src folder.");
|
||||||
|
|
||||||
return null;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static function createPath(... $path) : string
|
protected static function createPath(... $path) : string
|
||||||
|
|||||||
@ -8,6 +8,7 @@ use Notes\Attribute\Ignore;
|
|||||||
use Notes\Route\Attribute\Object\Route;
|
use Notes\Route\Attribute\Object\Route;
|
||||||
use Notes\Security\Attribute\Security;
|
use Notes\Security\Attribute\Security;
|
||||||
use Picea, Picea\Ui\Method\FormContext;
|
use Picea, Picea\Ui\Method\FormContext;
|
||||||
|
use Picea\Ui\Method\FormContextInterface;
|
||||||
use TheBugs\Email\MailerInterface;
|
use TheBugs\Email\MailerInterface;
|
||||||
use Storage\{ Cookie, Session };
|
use Storage\{ Cookie, Session };
|
||||||
use League\CommonMark\CommonMarkConverter;
|
use League\CommonMark\CommonMarkConverter;
|
||||||
@ -20,9 +21,6 @@ use function file_get_contents;
|
|||||||
#[Route(method: [ "GET", "POST" ])]
|
#[Route(method: [ "GET", "POST" ])]
|
||||||
trait ControllerTrait {
|
trait ControllerTrait {
|
||||||
|
|
||||||
##[Inject]
|
|
||||||
# public \Notes\Breadcrumb\Breadcrumb $breadcrumb;
|
|
||||||
|
|
||||||
#[Inject]
|
#[Inject]
|
||||||
public Session $session;
|
public Session $session;
|
||||||
|
|
||||||
@ -212,7 +210,7 @@ trait ControllerTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
public function pushContext(FormContext $context) : FormContext
|
public function pushContext(FormContextInterface $context) : FormContextInterface
|
||||||
{
|
{
|
||||||
$this->contextList[$context->formName ?? uniqid("context_")] = $context;
|
$this->contextList[$context->formName ?? uniqid("context_")] = $context;
|
||||||
|
|
||||||
@ -220,7 +218,7 @@ trait ControllerTrait {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[Ignore]
|
#[Ignore]
|
||||||
public function context(? string $name = null) : ? FormContext
|
public function context(? string $name = null) : ? FormContextInterface
|
||||||
{
|
{
|
||||||
return $name ? $this->contextList[$name] : array_values($this->contextList)[0] ?? null;
|
return $name ? $this->contextList[$name] : array_values($this->contextList)[0] ?? null;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,7 +5,9 @@ namespace Lean\Factory;
|
|||||||
use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, RedirectResponse, TextResponse};
|
use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, RedirectResponse, TextResponse};
|
||||||
use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse };
|
use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse };
|
||||||
use Laminas\Diactoros\Response;
|
use Laminas\Diactoros\Response;
|
||||||
|
use Laminas\Diactoros\StreamFactory;
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
class HttpFactory implements HttpFactoryInterface
|
class HttpFactory implements HttpFactoryInterface
|
||||||
{
|
{
|
||||||
@ -58,4 +60,9 @@ class HttpFactory implements HttpFactoryInterface
|
|||||||
{
|
{
|
||||||
return new FileDownloadResponse($path, $code, $headers);
|
return new FileDownloadResponse($path, $code, $headers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function createStream(string $content): StreamInterface
|
||||||
|
{
|
||||||
|
return (new StreamFactory())->createStream($content);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,6 +3,7 @@
|
|||||||
namespace Lean\Factory;
|
namespace Lean\Factory;
|
||||||
|
|
||||||
use Psr\Http\Message\ResponseInterface;
|
use Psr\Http\Message\ResponseInterface;
|
||||||
|
use Psr\Http\Message\StreamInterface;
|
||||||
|
|
||||||
interface HttpFactoryInterface
|
interface HttpFactoryInterface
|
||||||
{
|
{
|
||||||
@ -16,4 +17,5 @@ interface HttpFactoryInterface
|
|||||||
public static function createDownloadableResponse(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface;
|
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 createImageResponse(string $data, int $code = 200, array $headers = []) : ResponseInterface;
|
||||||
public static function createFileDownloadResponse(string $path, 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;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,18 +27,15 @@ class Kernel {
|
|||||||
|
|
||||||
public array $paths = [];
|
public array $paths = [];
|
||||||
|
|
||||||
public int $errorReporting = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_STRICT & ~E_NOTICE;
|
public int $errorReporting = E_ALL & ~E_USER_DEPRECATED & ~E_DEPRECATED & ~E_NOTICE;
|
||||||
|
|
||||||
public array $definitionFilePaths;
|
public array $definitionFilePaths;
|
||||||
|
|
||||||
public string $errorLogPath;
|
public string $errorLogPath;
|
||||||
|
|
||||||
public string $projectPath;
|
public function __construct(
|
||||||
|
public string $projectPath
|
||||||
public function __construct(string $projectPath)
|
) {
|
||||||
{
|
|
||||||
$this->projectPath = $projectPath;
|
|
||||||
|
|
||||||
$this->setEnvironment();
|
$this->setEnvironment();
|
||||||
$this->initializeEngine();
|
$this->initializeEngine();
|
||||||
$this->setupContainer();
|
$this->setupContainer();
|
||||||
|
|||||||
23
view/lean/block/since.phtml
Normal file
23
view/lean/block/since.phtml
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{% arguments \DateInterval $interval %}
|
||||||
|
|
||||||
|
{% if $interval->y %}
|
||||||
|
{% lang "lean.date.interval.years", [ 'years' => $interval->y ] %},
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if $interval->m %}
|
||||||
|
{% lang "lean.date.interval.months", [ 'months' => $interval->m ] %},
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if $interval->d %}
|
||||||
|
{% lang "lean.date.interval.days", [ 'days' => $interval->d ] %},
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if $interval->h %}
|
||||||
|
{% lang "lean.date.interval.hours", [ 'hours' => $interval->h ] %},
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if $interval->i %}
|
||||||
|
{% lang "lean.date.interval.minutes", [ 'minutes' => $interval->i ] %}
|
||||||
|
{% else %}
|
||||||
|
{% lang "lean.date.interval.seconds", [ 'seconds' => $interval->s ] %}
|
||||||
|
{% endif %}
|
||||||
@ -9,7 +9,7 @@
|
|||||||
<div class="title">{% _ "title" %}</div>
|
<div class="title">{% _ "title" %}</div>
|
||||||
<div class="subtitle">{% _ "subtitle" %}</div>
|
<div class="subtitle">{% _ "subtitle" %}</div>
|
||||||
<div class="content">{% _ "message" %}</div>
|
<div class="content">{% _ "message" %}</div>
|
||||||
<u><a href="#" onclick="history.back()">{% _ "back" %}</a></u>
|
<u><a href="{% url %}">{% _ "back" %}</a></u>
|
||||||
</div>
|
</div>
|
||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|
||||||
@ -22,5 +22,5 @@
|
|||||||
{% section "head.css" %}
|
{% section "head.css" %}
|
||||||
.title {font-size:2rem}
|
.title {font-size:2rem}
|
||||||
.subtitle {font-size:1.25rem; padding-top: 1rem;}
|
.subtitle {font-size:1.25rem; padding-top: 1rem;}
|
||||||
.content {padding-top:1rem}
|
.content {background: #f7f7f7;padding: 7px;color: #8c3c3c;max-height:300px;overflow-y:auto}
|
||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|||||||
@ -18,9 +18,3 @@
|
|||||||
{% view "lean/picto/undraw_lost" %}
|
{% view "lean/picto/undraw_lost" %}
|
||||||
</div>
|
</div>
|
||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|
||||||
{% section "head.css" %}
|
|
||||||
.title {font-size:2rem}
|
|
||||||
.subtitle {font-size:1.25rem; padding-top: 1rem;}
|
|
||||||
.content {padding-top:1rem}
|
|
||||||
{% endsection %}
|
|
||||||
|
|||||||
@ -18,9 +18,3 @@
|
|||||||
{% view "lean/picto/undraw_error" %}
|
{% view "lean/picto/undraw_error" %}
|
||||||
</div>
|
</div>
|
||||||
{% endsection %}
|
{% endsection %}
|
||||||
|
|
||||||
{% section "head.css" %}
|
|
||||||
.title {font-size:2rem}
|
|
||||||
.subtitle {font-size:1.25rem; padding-top: 1rem;}
|
|
||||||
.content {background: #f7f7f7;padding: 7px;color: #8c3c3c;max-height:300px;overflow-y:auto}
|
|
||||||
{% endsection %}
|
|
||||||
|
|||||||
@ -10,14 +10,14 @@
|
|||||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
body {background:#272822}
|
body {background:#272822;min-height:100vh;}
|
||||||
#main-content {min-height: 100vh;width: 100vw;align-items:center;justify-content: center;}
|
#main-content {min-height: 100vh;width: 100vw;align-items:center;justify-content: center;}
|
||||||
#wrapper-content {max-width:960px; max-height:65vh;flex-direction:row-reverse; margin:0 10vw}
|
#wrapper-content {max-width:960px; max-height:65vh;flex-direction:row-reverse; margin:0 10vw}
|
||||||
#wrapper-content .content-right {background:#efefef;padding:5vh 2vw;align-items:center;display:flex;justify-content:center; width:100%;border-radius:6px 0 0 6px}
|
#wrapper-content .content-right {background:#efefef;padding:5vh 2vw;align-items:center;display:flex;justify-content:center; width:100%;border-radius:6px 0 0 6px}
|
||||||
#wrapper-content .content-left {background:#ffffff;padding:5vh 2vw;border-radius:0 6px 6px 0;display:flex;align-items:center;justify-content: center}
|
#wrapper-content .content-left {background:#ffffff;padding:5vh 2vw;border-radius:0 6px 6px 0;display:flex;align-items:center;justify-content: center}
|
||||||
|
|
||||||
.form-user-login {width:80%;}
|
.form-user-login {width:80%;}
|
||||||
.picto-login svg {max-width:100%;}
|
.picto-login svg {max-width:100%;width:100%;max-height:33vh}
|
||||||
|
|
||||||
{% section "head.css" %}{% endsection %}
|
{% section "head.css" %}{% endsection %}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 40 KiB After Width: | Height: | Size: 42 KiB |
5
view/lean/picto/undraw_error.phtml~
Normal file
5
view/lean/picto/undraw_error.phtml~
Normal file
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
Loading…
x
Reference in New Issue
Block a user