24 Commits
Author SHA1 Message Date
mcndave 583580e068 Merge branch 'master' of https://git.mcnd.ca/mcndave/lean 2025-02-04 08:46:58 -05:00
mcndave 5b7da3237f - Added email pattern matcher 2025-02-04 08:46:50 -05:00
mcndave 2bc0c9e56f - Small change of isRoute method 2025-02-03 01:29:06 +00:00
Dave Mc Nicoll cebb213830 - Authorization problem now sends 403 error as it should 2024-12-09 21:59:16 +00:00
mcndave 8e29b0513a - Added RememberMe middleware in skeleton 2024-12-09 20:51:55 +00:00
mcndave 7f549a377a - Fixed definitions default paths 2024-12-09 20:51:25 +00:00
mcndave f87bccb3ab - Set middlewares definition as add() by default 2024-12-05 15:34:02 -05:00
mcndave 212dbd17c0 - Now using attributes injection based on PHP-DI's documentation suggestion 2024-11-30 00:54:42 +00:00
mcndave f462fcc597 - Added default values to routing 2024-11-22 20:47:06 -05:00
mcndave 13d306aec9 Merge branch 'master' of https://git.mcnd.ca/mcndave/lean 2024-11-21 19:15:53 -05:00
mcndave 07613bf1cb - Small work done on calendar widget 2024-11-21 19:15:39 -05:00
Dave Mc Nicoll 4e28917b96 - Added definition loading ordering 2024-11-18 16:45:09 -05:00
Dave Mc Nicoll 163df3f4ba - Added CLI support 2024-11-11 20:20:25 +00:00
mcndave 3320dc47c1 - Some minor fixes in controllertrait (ignore attribute) 2024-11-10 13:08:49 +00:00
mcndave 4484dc8985 - Fixed default privileges 2024-11-08 18:33:37 +00:00
mcndave 1d61ff87e4 - ORM missed some 'use' statements, added a add() for routes middleware and Cookie var is now set into ControllerTrait 2024-10-29 13:39:11 +00:00
Dave Mc Nicoll 0cc9a8a893 Merge branch 'master' of https://git.mcnd.ca/mcndave/lean 2024-10-17 18:21:00 +00:00
Dave Mc Nicoll fd8fa7695e - Fixed overridding of routes definition of multiple route with same names
- Corrected a bug withing the Pagination widget if there was only one page of result
2024-10-17 18:20:02 +00:00
mcndave 0581f378a5 - Fixed Skeleton and ORM missing namespacing 2024-10-17 17:21:56 +00:00
mcndave 708af80fa2 - Merged 2024-10-11 19:24:25 +00:00
mcndave 1f828eb022 - Tmp code allowing to override routes 2024-10-09 14:34:54 -04:00
mcndave 959a182d16 - Fixed the Composer.json autoload ; now config are included inside the definition 2024-09-27 14:29:46 -04:00
mcndave ffe66e522c Merge branch 'master' of https://git.mcnd.ca/mcndave/lean 2024-09-25 14:38:02 -04:00
mcndave 730ce7474e - WIP on Kernel loading and Lean's autoload. Fixed some breadcrumb inconsistencies also 2024-09-25 14:37:45 -04:00
17 changed files with 161 additions and 115 deletions

No files matched your search

+2 -2
View File
@@ -29,8 +29,8 @@ return [
return function(array $errorData) { return function(array $errorData) {
return HttpFactory::createJsonResponse($errorData + [ return HttpFactory::createJsonResponse($errorData + [
'api.error' => "Authorization failed", 'api.error' => "Authorization failed",
'api.datetime' => (new \DateTime)->format(\DateTime::ATOM), 'api.datetime' => (new \DateTime)->format(\DateTime::ISO8601),
], 401); ], 403);
}; };
}, },
+1 -2
View File
@@ -60,12 +60,11 @@ return [
} }
$routing->response = $redirect; $routing->response = $redirect;
return; return;
} }
} }
if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::class) ) { if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::class) && $container->has(SecurityHandler::class) ) {
if ( $forbidden = $container->get(SecurityHandler::class)->taxus($class, $method, $object->user ?? null) ) { if ( $forbidden = $container->get(SecurityHandler::class)->taxus($class, $method, $object->user ?? null) ) {
$routing->response = $forbidden; $routing->response = $forbidden;
+2 -2
View File
@@ -1,6 +1,7 @@
<?php <?php
use Ulmus\Container\AdapterProxy; use Ulmus\Container\AdapterProxy;
use Ulmus\ConnectionAdapter;
use function DI\autowire, DI\create, DI\get, DI\add; use function DI\autowire, DI\create, DI\get, DI\add;
@@ -9,9 +10,8 @@ return [
AdapterProxy::class, AdapterProxy::class,
]), ]),
AdapterProxy::class => function (ContainerInterface $c) { AdapterProxy::class => function (Psr\Container\ContainerInterface $c) {
return new AdapterProxy( return new AdapterProxy(
$c->get('lean:adapter.sqlite'),
$c->get(ConnectionAdapter::class), $c->get(ConnectionAdapter::class),
); );
}, },
+5 -3
View File
@@ -1,6 +1,6 @@
<?php <?php
use function DI\autowire, DI\create, DI\get; use function DI\autowire, DI\create, DI\get, DI\add;
use League\Route\Strategy\ApplicationStrategy, use League\Route\Strategy\ApplicationStrategy,
League\Route\Router; League\Route\Router;
@@ -49,10 +49,10 @@ return [
"dump", "errorHandler", SessionMiddleware::class, CronardMiddleware::class, Mcnd\Event\EventMiddleware::class, Mcnd\CLI\CliMiddleware::class, "dump", "errorHandler", SessionMiddleware::class, CronardMiddleware::class, Mcnd\Event\EventMiddleware::class, Mcnd\CLI\CliMiddleware::class,
], ],
'app.middlewares' => [ 'app.middlewares' => add([
# HeaderAuthenticationMiddleware::class, # HeaderAuthenticationMiddleware::class,
# PostRequestAuthenticationMiddleware::class, # PostRequestAuthenticationMiddleware::class,
], ]),
Lean\Routing\RouteDefinitionInterface::class => function($c) { Lean\Routing\RouteDefinitionInterface::class => function($c) {
return function (ContainerInterface $container) { return function (ContainerInterface $container) {
@@ -68,6 +68,8 @@ return [
} }
} }
$router->addPatternMatcher('email', '[^@ \t\r\n]+@[^@ \t\r\n]+\.[^@ \t\r\n]+');
$routing = $container->get(Lean\Routing::class); $routing = $container->get(Lean\Routing::class);
$routing->registerRoute($container, getenv('URL_BASE')); $routing->registerRoute($container, getenv('URL_BASE'));
+17 -31
View File
@@ -2,14 +2,11 @@
use Taxus\Privilege; use Taxus\Privilege;
use function DI\autowire, DI\create, DI\get; use function DI\{ autowire, add, create, get };
$dir = getenv("META_PATH") . "/definitions"; $dir = dirname(__DIR__, 2);
return array_merge( return [
Lean\Lean::autoloadDefinitionsFromComposerExtra(),
[
'%APPKEY%' => [ '%APPKEY%' => [
'picea' => [ 'picea' => [
'context' => "%ESCAPED_NAMESPACE%\\View", 'context' => "%ESCAPED_NAMESPACE%\\View",
@@ -18,46 +15,35 @@ return array_merge(
], ],
'ulmus' => [ 'ulmus' => [
'entities' => [ '%ESCAPED_NAMESPACE%\\Entity' => getenv("PROJECT_PATH") . '/src/Entity/' ], 'entities' => [ '%ESCAPED_NAMESPACE%\\Entity' => implode(DIRECTORY_SEPARATOR, [ $dir, 'src', 'Entity', '' ]) ],
], ],
'routes' => [ 'routes' => [
'%ESCAPED_NAMESPACE%\\Controller' => getenv("PROJECT_PATH") . '/src/Controller/', '%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ $dir, 'src', 'Controller', '' ]),
], ],
'events' => [ 'events' => [
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]), '%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ $dir, 'src', 'Controller', '' ]),
], ],
'cronard' => [ 'cronard' => [
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]), '%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ $dir, 'src', 'Controller', '' ]),
], ],
'cli' => [ 'cli' => [
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]), '%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ $dir, 'src', 'Controller', '' ]),
], ],
'taxus' => [ 'taxus' => [
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ], 'is_dev' => [ 'dev' => "Can manage almost everything in this application."],
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ], 'is_admin' => [ 'admin' => "Can manage almost everything in this application."],
[ new Privilege("user", "Is an authenticated user."), "is_user" ], 'is_moderator' => [ 'moderator' => "Can moderate this application."],
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ], 'is_user' => [ 'user' => "Is an authenticated user."],
'is_anonymous' => [ 'anonymous' => "Is an anonymous (unauthenticated) user."],
] ]
], ],
'app.middlewares' => [], 'app.middlewares' => \DI\add([
], Ulmus\User\Middleware\RememberMeMiddleware::class,
]),
require("$dir/auth.php"), ];
require("$dir/storage.php"),
require("$dir/security.php"),
require("$dir/env/" . getenv('APP_ENV') . ".php"),
[
'config' => function () {
return array_merge_recursive(
Lean\Lean::autoloadConfigFromComposerExtra(),
require(getenv("META_PATH")."/config.php")
);
}
]
);
-7
View File
@@ -16,11 +16,4 @@ return [
return $adapter; return $adapter;
}, },
AdapterProxy::class => function (ContainerInterface $c) {
return new AdapterProxy(
$c->get('lean:adapter.sqlite'),
$c->get(ConnectionAdapter::class)
);
},
]; ];
-2
View File
@@ -23,8 +23,6 @@ new class(dirname(__DIR__)) extends \Lean\Kernel {
{ {
$this->errorLogPath = getenv("LOGS_PATH") . DIRECTORY_SEPARATOR. date("Y-m").".log"; $this->errorLogPath = getenv("LOGS_PATH") . DIRECTORY_SEPARATOR. date("Y-m").".log";
$this->definitionFilePaths = Lean::getDefinitionsPathsFromComposer();
return parent::initializeEngine(); return parent::initializeEngine();
} }
+5 -1
View File
@@ -11,21 +11,25 @@ use Notes\Security\Attribute\Security;
use %NAMESPACE%\{ Entity, Lib, Form }; use %NAMESPACE%\{ Entity, Lib, Form };
use Mcnd\Event\EventManager; use Mcnd\Event\EventManager;
use Ulmus\User\Entity\UserInterface; use Notes\Attribute\Ignore;use Ulmus\User\Entity\UserInterface;
#[Security(locked: false)] #[Security(locked: false)]
#[Route(method: ['GET', 'POST', ])] #[Route(method: ['GET', 'POST', ])]
trait ControllerTrait { trait ControllerTrait {
use \Lean\ControllerTrait; use \Lean\ControllerTrait;
#[Ignore]
public ? UserInterface $user; public ? UserInterface $user;
#[Ignore]
protected EventManager $eventManager; protected EventManager $eventManager;
#[Ignore]
public function __construct(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) { public function __construct(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
$this->initializeController($picea, $session, $user, $breadcrumb, $eventManager); $this->initializeController($picea, $session, $user, $breadcrumb, $eventManager);
} }
#[Ignore]
public function initializeController(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) { public function initializeController(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
$this->picea = $picea; $this->picea = $picea;
$this->session = $session; $this->session = $session;
+4
View File
@@ -38,9 +38,13 @@ class ApplicationStrategy extends Strategy\ApplicationStrategy {
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
{ {
if (php_sapi_name() !== 'cli' and ! defined('STDIN')) {
return $this->throw404($request); return $this->throw404($request);
} }
return $handler->handle($request);;
}
public function throw404(ServerRequestInterface $request) : ResponseInterface public function throw404(ServerRequestInterface $request) : ResponseInterface
{ {
if ( getenv('DEBUG') && $this->di->has(\Picea\Asset\Asset::class) ) { if ( getenv('DEBUG') && $this->di->has(\Picea\Asset\Asset::class) ) {
+16 -13
View File
@@ -2,29 +2,38 @@
namespace Lean; namespace Lean;
use DI\Attribute\Inject;
use Lean\Factory\HttpFactory; use Lean\Factory\HttpFactory;
use Notes\Attribute\Ignore; 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 TheBugs\Email\MailerInterface; use TheBugs\Email\MailerInterface;
use Storage\Session; use Storage\{ Cookie, Session };
use League\CommonMark\CommonMarkConverter; use League\CommonMark\CommonMarkConverter;
use Psr\Http\Message\{ ServerRequestInterface, ResponseInterface }; use Psr\Http\Message\{ ServerRequestInterface, ResponseInterface };
use function file_get_contents; use function file_get_contents;
#[Security(locked: true, realm: "Protected Area")] #[Security(locked: false, realm: "Protected Area")]
#[Route(method: [ "GET", "POST" ])] #[Route(method: [ "GET", "POST" ])]
trait ControllerTrait { trait ControllerTrait {
public ? \Notes\Breadcrumb\Breadcrumb $breadcrumb;
public ? Session $session; #[Inject]
public \Notes\Breadcrumb\Breadcrumb $breadcrumb;
public ? Picea\Picea $picea; #[Inject]
public Session $session;
public ? MailerInterface $mailer; #[Inject]
public Cookie $cookie;
#[Inject]
public Picea\Picea $picea;
#[Inject]
public MailerInterface $mailer;
public array $contextList = []; public array $contextList = [];
@@ -217,12 +226,6 @@ trait ControllerTrait {
#[Ignore] #[Ignore]
public function isRoute(mixed $name, ServerRequestInterface $request) : bool public function isRoute(mixed $name, ServerRequestInterface $request) : bool
{ {
foreach((array) $name as $item) { return $request->getAttribute('lean.route')->match($name);
if ( fnmatch($item, $request->getAttribute('lean.route')->name) ) {
return true;
}
}
return false;
} }
} }
+13 -5
View File
@@ -29,9 +29,7 @@ class Kernel {
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_STRICT & ~E_NOTICE;
public string $definitionFilePath; public array $definitionFilePaths;
public array $definitionFilePaths = [];
public string $errorLogPath; public string $errorLogPath;
@@ -108,6 +106,8 @@ class Kernel {
{ {
$containerBuilder = new ContainerBuilder(); $containerBuilder = new ContainerBuilder();
$containerBuilder->useAttributes(true);
if (getenv("APP_ENV") === "prod") { if (getenv("APP_ENV") === "prod") {
if (getenv("CACHE_PATH")) { if (getenv("CACHE_PATH")) {
# check if ACPU is there first, $containerBuilder->enableDefinitionCache(); # check if ACPU is there first, $containerBuilder->enableDefinitionCache();
@@ -124,14 +124,22 @@ class Kernel {
} }
} }
if ($this->definitionFilePath ?? false) { foreach(Lean::getDefinitionsPathsFromComposer() as $path) {
$containerBuilder->addDefinitions($this->definitionFilePath); $containerBuilder->addDefinitions($path);
} }
foreach($this->definitionFilePaths ?? [] as $path) { foreach($this->definitionFilePaths ?? [] as $path) {
$containerBuilder->addDefinitions($path); $containerBuilder->addDefinitions($path);
} }
$containerBuilder->addDefinitions([
'config' => function () {
return array_merge_recursive(
Lean::autoloadConfigFromComposerExtra(), []
);
}
]);
$this->container = $containerBuilder->build(); $this->container = $containerBuilder->build();
return $this; return $this;
+27 -26
View File
@@ -1,6 +1,5 @@
<?php <?php
namespace Lean; namespace Lean;
use Psr\Container\ContainerInterface; use Psr\Container\ContainerInterface;
@@ -22,13 +21,16 @@ class Lean
protected function loadApplications() : void protected function loadApplications() : void
{ {
$list = $this->container->get('config')['lean']['autoload'] ?? []; $list = array_filter($this->container->get('config')['lean']['autoload'] ?? []);
if (! $list ) { if (! $list ) {
throw new \Exception("You must provide at least one application to autoload within your config file ( 'lean' => 'autoload' => [] )"); throw new \Exception("You must provide at least one application to autoload within your config file ( 'lean' => 'autoload' => [] )");
} }
foreach(array_filter($list) as $application) { # Allows 'lean.default' and [ 'lean.default', 100 ] which allows ordering of apps loading.
usort($list, fn($e1, $e2) => ( is_array($e1) ? $e1[1] : 0 ) <=> ( is_array($e2) ? $e2[1] : 0 ));
foreach(array_map(fn($item) => is_array($item) ? $item[0] : $item, $list) as $application) {
if ( $this->container->has($application) ) { if ( $this->container->has($application) ) {
$this->applications[] = ( new Application($application) )->fromArray($this->container->get($application)); $this->applications[] = ( new Application($application) )->fromArray($this->container->get($application));
} }
@@ -166,29 +168,23 @@ class Lean
$list = []; $list = [];
foreach(Composer::readComposerLock()['packages'] as $package) { foreach(Composer::readComposerLock()['packages'] as $package) {
$order = $package['extra']['lean']['autoload']['order'] ?? 0;
foreach($package['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) { foreach($package['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) {
$list[] = static::pathFromPackage($package, $autoload); $list[] = [ static::pathFromPackage($package, $autoload), $order ];
} }
} }
foreach(Composer::readComposerJson()['extra']['lean']['autoload']['definitions'] ?? [] ?? [] as $autoload) { foreach(Composer::readComposerJson()['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) {
$list[] = getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . $autoload; $order = $package['extra']['lean']['autoload']['order'] ?? 1000;
$list[] = [ getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . $autoload, $order ];
} }
return $list; # Allows 'lean.default' and [ 'lean.default', 100 ] which allows ordering of apps loading.
} usort($list, fn($e1, $e2) => $e1[1] <=> $e2[1]);
public static function autoloadDefinitionsFromComposerExtra() : array return array_column($list, 0);
{
$list = [];
foreach(Composer::readComposerLock()['packages'] as $package) {
foreach($package['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) {
$list = array_replace($list, static::loadFromPackage($package, $autoload));
}
}
return $list;
} }
public static function autoloadConfigFromComposerExtra() : array public static function autoloadConfigFromComposerExtra() : array
@@ -201,14 +197,22 @@ class Lean
} }
} }
foreach(Composer::readComposerJson()['extra']['lean']['autoload']['config'] ?? [] as $autoload) {
$list = array_merge_recursive($list, static::loadFromPackage(null, $autoload));
}
return $list; return $list;
} }
protected static function pathFromPackage(array $package, array|string $autoload) : string protected static function pathFromPackage(?array $package, array|string $autoload) : string
{ {
if ($package === null) {
$filepath = getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . $autoload;
}
else {
$vendor = getenv('VENDOR_DIR') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3); $vendor = getenv('VENDOR_DIR') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
$filepath = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload; $filepath = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
}
if (! file_exists($filepath)) { if (! file_exists($filepath)) {
throw new \InvalidArgumentException("Given definition filepath do not exists '$filepath'"); throw new \InvalidArgumentException("Given definition filepath do not exists '$filepath'");
@@ -217,7 +221,7 @@ class Lean
return $filepath; return $filepath;
} }
protected static function loadFromPackage(array $package, array|string $autoload) : false|array protected static function loadFromPackage(? array $package, array|string $autoload) : false|array
{ {
$list = []; $list = [];
@@ -230,12 +234,9 @@ class Lean
return require($file); return require($file);
} }
else {
$func = implode('::', array_merge([ key($autoload) ], $autoload)); $func = implode('::', array_merge([ key($autoload) ], $autoload));
return call_user_func($func); return call_user_func($func);
} }
return false;
}
} }
+41 -2
View File
@@ -5,6 +5,7 @@ namespace Lean;
use League\Route\RouteGroup, use League\Route\RouteGroup,
League\Route\Router; League\Route\Router;
use Notes\Route\Attribute\Method\Route;
use Psr\Http\Message\ServerRequestInterface, use Psr\Http\Message\ServerRequestInterface,
Psr\Http\Message\ResponseInterface, Psr\Http\Message\ResponseInterface,
Psr\Container\ContainerInterface; Psr\Container\ContainerInterface;
@@ -17,6 +18,8 @@ class Routing {
public ResponseInterface $response; public ResponseInterface $response;
public array $overriddenRoutes = [];
public function __construct( public function __construct(
public Router $router, public Router $router,
public RouteFetcher $fetcher, public RouteFetcher $fetcher,
@@ -25,12 +28,12 @@ class Routing {
public function registerRoute(ContainerInterface $container, string $urlBase) { public function registerRoute(ContainerInterface $container, string $urlBase) {
$this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) { $this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) {
foreach($this->fetcher->compile() as $attribute) { foreach($this->fetchRoutesAttributes() as $attribute) {
$this->eventManager->execute(Event\RoutingCompileRoutes::class, $this, $attribute); $this->eventManager->execute(Event\RoutingCompileRoutes::class, $this, $attribute);
# Mapping every URLs from attributes in searched folders (Api, Controller, etc...) # Mapping every URLs from attributes in searched folders (Api, Controller, etc...)
foreach((array) $attribute->method as $method) { foreach((array) $attribute->method as $method) {
$route->map(strtoupper($method), $attribute->getRoute(), function (ServerRequestInterface $request, array $arguments) use ( $route->map(strtoupper($method), $attribute->getRegistrableRoute(), function (ServerRequestInterface $request, array $arguments) use (
$container, $route, $attribute $container, $route, $attribute
) : ResponseInterface { ) : ResponseInterface {
$class = $attribute->class; $class = $attribute->class;
@@ -47,4 +50,40 @@ class Routing {
} }
}); });
} }
public function fetchRoutesAttributes() : iterable
{
static $list = [];
if ($list) {
return $list;
}
foreach($this->fetcher->compile() as $routeAttribute) {
# Routes with differents methods can have the same name
$key = sprintf('{%s}~{%s}', $routeAttribute->name, $this->serializeMethods((array) $routeAttribute->method));
if ( isset($list[$key]) ) {
$this->overriddenRoutes[$key] = $list[$key];
}
$list[$key] = $routeAttribute;
}
return $list;
}
public function findOverriddenRoute(Route $route) : false|iterable
{
return array_filter($this->overriddenRoutes, fn($e) => $route->name === $e->name);
}
protected function serializeMethods(array $methods) : string
{
$methods = array_map('strtolower', $methods);
sort($methods);
return implode(':', $methods);
}
} }
+1 -1
View File
@@ -1 +1 @@
<svg id="e7dedc5b-fca6-4313-b5a0-e6297481e8ae" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1022.7" height="785.81" viewBox="0 0 1022.7 785.81"><defs><linearGradient id="af83dc26-9572-4816-b7a1-1af4f72ff554" x1="678.2" y1="821.79" x2="678.2" y2="493.4" gradientTransform="translate(-20.24 29.65) rotate(-2.31)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"/><stop offset="0.54" stop-color="gray" stop-opacity="0.12"/><stop offset="1" stop-color="gray" stop-opacity="0.1"/></linearGradient></defs><title>bug fixing</title><ellipse cx="468.63" cy="660.88" rx="425" ry="33" fill="#6c63ff" opacity="0.1"/><g opacity="0.1"><path d="M933.7,529.93c-2.54-7.71-12.84-11.26-23-7.92a24.76,24.76,0,0,0-4.23,1.83c-.65-.18-1.32-.34-2-.46a22.42,22.42,0,0,0,.63-6.79A24.6,24.6,0,0,0,916,495.12a24.63,24.63,0,0,0,10.86-21.47,23.76,23.76,0,0,0,8.23-9.32c4.9-9.7,2.87-20.6-4.54-24.35s-17.4,1.08-22.3,10.78a23.69,23.69,0,0,0-2.63,12.15,24.63,24.63,0,0,0-10.86,21.47,24.63,24.63,0,0,0-10.86,21.47A24.64,24.64,0,0,0,873,527.33a23.76,23.76,0,0,0-8.23,9.32,25.46,25.46,0,0,0-2.08,5.74,21.18,21.18,0,0,0-4.44-4.73,25.38,25.38,0,0,0-1-4.5c-3.34-10.17-12.3-16.37-20-13.83s-11.26,12.83-7.92,23a23.07,23.07,0,0,0,7.56,11.08,25.38,25.38,0,0,0,1,4.5c1.94,5.9,5.77,10.46,10.15,12.75a23.23,23.23,0,0,0-.83,3.9,25.29,25.29,0,0,0-7.54,14.91,25.27,25.27,0,0,0-7.54,14.92,24.63,24.63,0,0,0-5,6.81c-4.91,9.7-2.88,20.61,4.53,24.35s17.4-1.07,22.31-10.78a24.62,24.62,0,0,0,2.5-8.09,25.29,25.29,0,0,0,7.54-14.91,25.27,25.27,0,0,0,7.54-14.92A25.21,25.21,0,0,0,879,571.94,25.21,25.21,0,0,0,886.56,557a24.11,24.11,0,0,0,3.39-4,23.46,23.46,0,0,0,12.27-.77,24.76,24.76,0,0,0,4.23-1.83,23.2,23.2,0,0,0,13.42-.48C930,546.61,936.23,537.65,933.7,529.93Z" transform="translate(-88.65 -57.09)" fill="#3f3d56"/><g opacity="0.1"><path d="M915.77,499.53a21.5,21.5,0,0,1-3.44,2.75,23,23,0,0,1-1.11,8.43,26.18,26.18,0,0,0,2.1-3.43A24.64,24.64,0,0,0,915.77,499.53Z" transform="translate(-88.65 -57.09)"/><path d="M926.63,478.06a21.5,21.5,0,0,1-3.44,2.75,23,23,0,0,1-1.11,8.43,25.65,25.65,0,0,0,2.1-3.44A24.85,24.85,0,0,0,926.63,478.06Z" transform="translate(-88.65 -57.09)"/><path d="M902,470.07a21.91,21.91,0,0,1,.17-4.41,24.93,24.93,0,0,0-4.78,6.57,25.63,25.63,0,0,0-1.52,3.73A22.75,22.75,0,0,1,902,470.07Z" transform="translate(-88.65 -57.09)"/><path d="M833.07,600a23.59,23.59,0,0,1,2.95-3.38,22.92,22.92,0,0,1,.87-4,25.09,25.09,0,0,0-2.29,3.71A25.59,25.59,0,0,0,833.07,600Z" transform="translate(-88.65 -57.09)"/><path d="M840.61,585.1a23.59,23.59,0,0,1,2.95-3.38,23,23,0,0,1,.83-3.9l0,0a25.68,25.68,0,0,0-2.2,3.59A26.76,26.76,0,0,0,840.61,585.1Z" transform="translate(-88.65 -57.09)"/><path d="M904.9,521a20.82,20.82,0,0,1-3.43,2.74,22.45,22.45,0,0,1-.63,6.79,18.75,18.75,0,0,1,2,.46,24.76,24.76,0,0,1,4.23-1.83c10.18-3.34,20.47.21,23,7.92a11.68,11.68,0,0,1,.32,6c3.35-3.94,4.74-8.74,3.3-13.14-2.54-7.71-12.84-11.26-23-7.92a24.76,24.76,0,0,0-4.23,1.83c-.65-.18-1.32-.34-2-.46C904.65,522.59,904.79,521.8,904.9,521Z" transform="translate(-88.65 -57.09)"/><path d="M829.35,607.49a25.09,25.09,0,0,0-2.29,3.71,26.56,26.56,0,0,0-1.54,3.74,24.48,24.48,0,0,1,3-3.4A22.92,22.92,0,0,1,829.35,607.49Z" transform="translate(-88.65 -57.09)"/><path d="M891.09,491.54a22,22,0,0,1,.17-4.41,24.93,24.93,0,0,0-4.78,6.57,25.63,25.63,0,0,0-1.52,3.73A22.75,22.75,0,0,1,891.09,491.54Z" transform="translate(-88.65 -57.09)"/><path d="M875.4,579.1a24.29,24.29,0,0,1-1,4.38,26.67,26.67,0,0,0,2.09-3.44,25.49,25.49,0,0,0,1.63-4A24.23,24.23,0,0,1,875.4,579.1Z" transform="translate(-88.65 -57.09)"/><path d="M860.32,608.92a24.15,24.15,0,0,1-1,4.38,25.65,25.65,0,0,0,2.1-3.44,26.47,26.47,0,0,0,1.63-4A23.57,23.57,0,0,1,860.32,608.92Z" transform="translate(-88.65 -57.09)"/><path d="M867.86,594a24.11,24.11,0,0,1-1,4.38A26.67,26.67,0,0,0,869,595a25.49,25.49,0,0,0,1.63-4A24.23,24.23,0,0,1,867.86,594Z" transform="translate(-88.65 -57.09)"/><path d="M882.94,564.19a24,24,0,0,1-1,4.37,25.89,25.89,0,0,0,2.09-3.43,25.48,25.48,0,0,0,1.64-4.07A23.22,23.22,0,0,1,882.94,564.19Z" transform="translate(-88.65 -57.09)"/><path d="M833.57,526.48c7.72-2.53,16.68,3.66,20,13.83a25.68,25.68,0,0,1,1,4.51,21.18,21.18,0,0,1,4.44,4.73,25.53,25.53,0,0,1,2.08-5.75c.35-.68.73-1.33,1.12-2a21.07,21.07,0,0,0-4-4.18,25.38,25.38,0,0,0-1-4.5c-3.34-10.17-12.3-16.37-20-13.83-4.4,1.44-7.44,5.41-8.62,10.43A11.69,11.69,0,0,1,833.57,526.48Z" transform="translate(-88.65 -57.09)"/><path d="M869.37,534.48a21.85,21.85,0,0,1,.18-4.4,24.73,24.73,0,0,0-4.79,6.57,25.07,25.07,0,0,0-1.52,3.72A23,23,0,0,1,869.37,534.48Z" transform="translate(-88.65 -57.09)"/><path d="M880.23,513a21.85,21.85,0,0,1,.18-4.4,24.52,24.52,0,0,0-4.79,6.56,25.63,25.63,0,0,0-1.52,3.73A22.75,22.75,0,0,1,880.23,513Z" transform="translate(-88.65 -57.09)"/><path d="M852.78,623.83a24.25,24.25,0,0,1-1,4.39,25.73,25.73,0,0,0,3.73-7.49A23.57,23.57,0,0,1,852.78,623.83Z" transform="translate(-88.65 -57.09)"/></g><path d="M948.52,430.71a23.68,23Line truncated <svg id="e7dedc5b-fca6-4313-b5a0-e6297481e8ae" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="1022.7" height="785.81" viewBox="0 0 1022.7 785.81"><defs><linearGradient id="af83dc26-9572-4816-b7a1-1af4f72ff554" x1="678.2" y1="821.79" x2="678.2" y2="493.4" gradientTransform="translate(-20.24 29.65) rotate(-2.31)" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"/><stop offset="0.54" stop-color="gray" stop-opacity="0.12"/><stop offset="1" stop-color="gray" stop-opacity="0.1"/></linearGradient></defs><title>bug fixing</title><ellipse cx="468.63" cy="660.88" rx="425" ry="33" fill="#6c63ff" opacity="0.1"/><g opacity="0.1"><path d="M933.7,529.93c-2.54-7.71-12.84-11.26-23-7.92a24.76,24.76,0,0,0-4.23,1.83c-.65-.18-1.32-.34-2-.46a22.42,22.42,0,0,0,.63-6.79A24.6,24.6,0,0,0,916,495.12a24.63,24.63,0,0,0,10.86-21.47,23.76,23.76,0,0,0,8.23-9.32c4.9-9.7,2.87-20.6-4.54-24.35s-17.4,1.08-22.3,10.78a23.69,23.69,0,0,0-2.63,12.15,24.63,24.63,0,0,0-10.86,21.47,24.63,24.63,0,0,0-10.86,21.47A24.64,24.64,0,0,0,873,527.33a23.76,23.76,0,0,0-8.23,9.32,25.46,25.46,0,0,0-2.08,5.74,21.18,21.18,0,0,0-4.44-4.73,25.38,25.38,0,0,0-1-4.5c-3.34-10.17-12.3-16.37-20-13.83s-11.26,12.83-7.92,23a23.07,23.07,0,0,0,7.56,11.08,25.38,25.38,0,0,0,1,4.5c1.94,5.9,5.77,10.46,10.15,12.75a23.23,23.23,0,0,0-.83,3.9,25.29,25.29,0,0,0-7.54,14.91,25.27,25.27,0,0,0-7.54,14.92,24.63,24.63,0,0,0-5,6.81c-4.91,9.7-2.88,20.61,4.53,24.35s17.4-1.07,22.31-10.78a24.62,24.62,0,0,0,2.5-8.09,25.29,25.29,0,0,0,7.54-14.91,25.27,25.27,0,0,0,7.54-14.92A25.21,25.21,0,0,0,879,571.94,25.21,25.21,0,0,0,886.56,557a24.11,24.11,0,0,0,3.39-4,23.46,23.46,0,0,0,12.27-.77,24.76,24.76,0,0,0,4.23-1.83,23.2,23.2,0,0,0,13.42-.48C930,546.61,936.23,537.65,933.7,529.93Z" transform="translate(-88.65 -57.09)" fill="#3f3d56"/><g opacity="0.1"><path d="M915.77,499.53a21.5,21.5,0,0,1-3.44,2.75,23,23,0,0,1-1.11,8.43,26.18,26.18,0,0,0,2.1-3.43A24.64,24.64,0,0,0,915.77,499.53Z" transform="translate(-88.65 -57.09)"/><path d="M926.63,478.06a21.5,21.5,0,0,1-3.44,2.75,23,23,0,0,1-1.11,8.43,25.65,25.65,0,0,0,2.1-3.44A24.85,24.85,0,0,0,926.63,478.06Z" transform="translate(-88.65 -57.09)"/><path d="M902,470.07a21.91,21.91,0,0,1,.17-4.41,24.93,24.93,0,0,0-4.78,6.57,25.63,25.63,0,0,0-1.52,3.73A22.75,22.75,0,0,1,902,470.07Z" transform="translate(-88.65 -57.09)"/><path d="M833.07,600a23.59,23.59,0,0,1,2.95-3.38,22.92,22.92,0,0,1,.87-4,25.09,25.09,0,0,0-2.29,3.71A25.59,25.59,0,0,0,833.07,600Z" transform="translate(-88.65 -57.09)"/><path d="M840.61,585.1a23.59,23.59,0,0,1,2.95-3.38,23,23,0,0,1,.83-3.9l0,0a25.68,25.68,0,0,0-2.2,3.59A26.76,26.76,0,0,0,840.61,585.1Z" transform="translate(-88.65 -57.09)"/><path d="M904.9,521a20.82,20.82,0,0,1-3.43,2.74,22.45,22.45,0,0,1-.63,6.79,18.75,18.75,0,0,1,2,.46,24.76,24.76,0,0,1,4.23-1.83c10.18-3.34,20.47.21,23,7.92a11.68,11.68,0,0,1,.32,6c3.35-3.94,4.74-8.74,3.3-13.14-2.54-7.71-12.84-11.26-23-7.92a24.76,24.76,0,0,0-4.23,1.83c-.65-.18-1.32-.34-2-.46C904.65,522.59,904.79,521.8,904.9,521Z" transform="translate(-88.65 -57.09)"/><path d="M829.35,607.49a25.09,25.09,0,0,0-2.29,3.71,26.56,26.56,0,0,0-1.54,3.74,24.48,24.48,0,0,1,3-3.4A22.92,22.92,0,0,1,829.35,607.49Z" transform="translate(-88.65 -57.09)"/><path d="M891.09,491.54a22,22,0,0,1,.17-4.41,24.93,24.93,0,0,0-4.78,6.57,25.63,25.63,0,0,0-1.52,3.73A22.75,22.75,0,0,1,891.09,491.54Z" transform="translate(-88.65 -57.09)"/><path d="M875.4,579.1a24.29,24.29,0,0,1-1,4.38,26.67,26.67,0,0,0,2.09-3.44,25.49,25.49,0,0,0,1.63-4A24.23,24.23,0,0,1,875.4,579.1Z" transform="translate(-88.65 -57.09)"/><path d="M860.32,608.92a24.15,24.15,0,0,1-1,4.38,25.65,25.65,0,0,0,2.1-3.44,26.47,26.47,0,0,0,1.63-4A23.57,23.57,0,0,1,860.32,608.92Z" transform="translate(-88.65 -57.09)"/><path d="M867.86,594a24.11,24.11,0,0,1-1,4.38A26.67,26.67,0,0,0,869,595a25.49,25.49,0,0,0,1.63-4A24.23,24.23,0,0,1,867.86,594Z" transform="translate(-88.65 -57.09)"/><path d="M882.94,564.19a24,24,0,0,1-1,4.37,25.89,25.89,0,0,0,2.09-3.43,25.48,25.48,0,0,0,1.64-4.07A23.22,23.22,0,0,1,882.94,564.19Z" transform="translate(-88.65 -57.09)"/><path d="M833.57,526.48c7.72-2.53,16.68,3.66,20,13.83a25.68,25.68,0,0,1,1,4.51,21.18,21.18,0,0,1,4.44,4.73,25.53,25.53,0,0,1,2.08-5.75c.35-.68.73-1.33,1.12-2a21.07,21.07,0,0,0-4-4.18,25.38,25.38,0,0,0-1-4.5c-3.34-10.17-12.3-16.37-20-13.83-4.4,1.44-7.44,5.41-8.62,10.43A11.69,11.69,0,0,1,833.57,526.48Z" transform="translate(-88.65 -57.09)"/><path d="M869.37,534.48a21.85,21.85,0,0,1,.18-4.4,24.73,24.73,0,0,0-4.79,6.57,25.07,25.07,0,0,0-1.52,3.72A23,23,0,0,1,869.37,534.48Z" transform="translate(-88.65 -57.09)"/><path d="M880.23,513a21.85,21.85,0,0,1,.18-4.4,24.52,24.52,0,0,0-4.79,6.56,25.63,25.63,0,0,0-1.52,3.73A22.75,22.75,0,0,1,880.23,513Z" transform="translate(-88.65 -57.09)"/><path d="M852.78,623.83a24.25,24.25,0,0,1-1,4.39,25.73,25.73,0,0,0,3.73-7.49A23.57,23.57,0,0,1,852.78,623.83Z" transform="translate(-88.65 -57.09)"/></g><path d="M948.52,430.71a23.68,23Line truncated

Before

Width:  |  Height:  |  Size: 39 KiB

After

Width:  |  Height:  |  Size: 32 KiB

+21 -16
View File
@@ -1,28 +1,33 @@
<ol class="breadcrumb "> {% if isset($this->breadcrumb) %}
<li class="breadcrumb-item"><a href="{% url '' %}"><i class="fas fa-fw fa-tachometer-alt"></i> Tableau de bord</a></li> {% php $routeTree = $this->breadcrumb->getRouteTree($this->session->get('lean.route')) %}
{% foreach $this->breadcrumb ?? [] as $crumb %} {% if count($routeTree) %}
<li class="breadcrumb-item {{ ( $crumb['active'] ?? false ) ? 'active' : '' }}"> <ol class="breadcrumb mb-4 px-3 py-2">
{% if ! ($crumb['active'] ?? false) %} {% foreach $routeTree as $index => $crumb %}
{? $last = $crumb ?} <li class="breadcrumb-item {% if $crumb->current %}active{% endif %}">
{% if ! $crumb->current %}
{% php $last = $crumb %}
<a href="{% url $crumb['url'] %}"> <a href="{% route $crumb->routeAnnotation->name %}">
{% if $crumb['icon'] ?? false %} {% if $crumb->icon ?? false %}
<i class="fa fa-{{ $crumb['icon'] }}"></i> <i class="fa fa-{{ $crumb->icon }}"></i>
{% endif %} {% endif %}
{{ $crumb['title'] }} <span>{{ lang($crumb->lang, get_defined_vars()) }}</span>
</a> </a>
{% else %} {% else %}
{% if $crumb['icon'] ?? false %} {% if $crumb->icon ?? false %}
<i class="fa fa-{{ $crumb['icon'] }}"></i> <i class="fa fa-{{ $crumb->icon }}"></i>
{% endif %} {% endif %}
<span>{{ $crumb['title'] }}</span>
<span>{{ lang($crumb->lang, get_defined_vars()) }}</span>
{% endif %} {% endif %}
</li> </li>
{% endforeach %} {% endforeach %}
{% if $last ?? false %} {# if $last ?? false %}
<li class="breadcrumb-last-item ml-auto"><a href="{{ url( $last['url']) }}"><i class="fas fa-chevron-circle-left"></i> Retour</a></li> <li class="breadcrumb-last-item ml-auto"><a href="{{ ( $last['route'] ?? false ) ? $last['route'] : url($last['url']) }}"><i class="fas fa-chevron-circle-left"></i> Retour</a></li>
{% endif %} {% endif #}
</ol> </ol>
{% endif %}
{% endif %}
+4 -2
View File
@@ -31,15 +31,17 @@
{% foreach range(0, 5) as $week %} {% foreach range(0, 5) as $week %}
<div class="week"> <div class="week">
{% foreach range(0, 6) as $day %} {% foreach range(0, 6) as $day %}
{% php $dayType = in_array($day, [0, 6]) ? 'week-end' : 'week-day' %}
{% if ( $week * 6 + $day >= $index ) && ( $currentDay < $dayCount ) %} {% if ( $week * 6 + $day >= $index ) && ( $currentDay < $dayCount ) %}
{% php $currentDay++; %} {% php $currentDay++; %}
{% slot "day.content", new \DateTime("$year-$month-$currentDay"), date("$year-$month-$currentDay") === date('Y-n-j') %} {% slot "day.content", new \DateTime("$year-$month-$currentDay"), date("$year-$month-$currentDay") === date('Y-n-j') %}
<div class="day-box {{ $today ? 'today' : '' }}">{{ $date->format('d') }}</div> <div class="day-box {{ $today ? 'today' : '' }} {{ $dayType }}">{{ $date->format('d') }}</div>
{% endslot %} {% endslot %}
{% else %} {% else %}
{% slot "day.empty", $day, $month, $year %} {% slot "day.empty", $day, $month, $year %}
<div class="day-box"></div> <div class="day-box {{ $dayType }}"></div>
{% endslot %} {% endslot %}
{% endif %} {% endif %}
{% endforeach %} {% endforeach %}
+2
View File
@@ -6,9 +6,11 @@
<li class="page-item {{ $page === 1 ? 'active' : '' }}"><a class="page-link" href="{% url.parameters $url, [ 'page' => 1 ] + get() %}">1</a></li> <li class="page-item {{ $page === 1 ? 'active' : '' }}"><a class="page-link" href="{% url.parameters $url, [ 'page' => 1 ] + get() %}">1</a></li>
{% if $pageCount > 1%}
{% foreach range(2, $pageCount < $maxPage ? $pageCount : $maxPage) as $pageIndex %} {% foreach range(2, $pageCount < $maxPage ? $pageCount : $maxPage) as $pageIndex %}
<li class="page-item {{ $page === $pageIndex ? 'active' : '' }}"><a class="page-link" href="{% url.parameters $url, [ 'page' => $pageIndex ] + get() %}">{{ $pageIndex }}</a></li> <li class="page-item {{ $page === $pageIndex ? 'active' : '' }}"><a class="page-link" href="{% url.parameters $url, [ 'page' => $pageIndex ] + get() %}">{{ $pageIndex }}</a></li>
{% endforeach %} {% endforeach %}
{% endif %}
<li class="page-item {{ $page === $pageCount ? 'disabled' : '' }}"><a class="page-link" href="{% url.parameters $url, [ 'page' => $page + 1 ] + get() %}">{% lang "lean.widget.pagination.next" %}</a></li> <li class="page-item {{ $page === $pageCount ? 'disabled' : '' }}"><a class="page-link" href="{% url.parameters $url, [ 'page' => $page + 1 ] + get() %}">{% lang "lean.widget.pagination.next" %}</a></li>
</ul> </ul>