Compare commits
	
		
			No commits in common. "0cc9a8a893178fa5f182d3d45b326c9ff56c0f1d" and "0581f378a5506a2e7f476ad4ae7614fafa23d958" have entirely different histories.
		
	
	
		
			0cc9a8a893
			...
			0581f378a5
		
	
		
@ -60,11 +60,12 @@ return [
 | 
				
			|||||||
                                }
 | 
					                                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                $routing->response = $redirect;
 | 
					                                $routing->response = $redirect;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                                return;
 | 
					                                return;
 | 
				
			||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                        if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::class) && $container->has(SecurityHandler::class) ) {
 | 
					                        if ( $securityHandler->isLocked($class, $method) && $container->has(Taxus::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;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -8,18 +8,20 @@ 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 League\CommonMark\CommonMarkConverter;
 | 
					use League\CommonMark\CommonMarkConverter;
 | 
				
			||||||
 | 
					use Storage\{ Session, Cookie };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use Psr\Http\Message\{ ServerRequestInterface, ResponseInterface };
 | 
					use Psr\Http\Message\{ ServerRequestInterface, ResponseInterface };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
use function file_get_contents;
 | 
					use function file_get_contents;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#[Security(locked: false, realm: "Protected Area")]
 | 
					#[Security(locked: true, realm: "Protected Area")]
 | 
				
			||||||
#[Route(method: [ "GET", "POST" ])]
 | 
					#[Route(method: [ "GET", "POST" ])]
 | 
				
			||||||
trait ControllerTrait {
 | 
					trait ControllerTrait {
 | 
				
			||||||
    public ? \Notes\Breadcrumb\Breadcrumb $breadcrumb;
 | 
					    public ? \Notes\Breadcrumb\Breadcrumb $breadcrumb;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    public ? Cookie $cookie;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ? Session $session;
 | 
					    public ? Session $session;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public ? Picea\Picea $picea;
 | 
					    public ? Picea\Picea $picea;
 | 
				
			||||||
 | 
				
			|||||||
@ -5,7 +5,6 @@ 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;
 | 
				
			||||||
@ -18,7 +17,7 @@ class Routing {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public ResponseInterface $response;
 | 
					    public ResponseInterface $response;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public array $overriddenRoutes = [];
 | 
					    protected array $registeredRoutes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function __construct(
 | 
					    public function __construct(
 | 
				
			||||||
        public Router $router,
 | 
					        public Router $router,
 | 
				
			||||||
@ -27,19 +26,19 @@ class Routing {
 | 
				
			|||||||
    ) { }
 | 
					    ) { }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public function registerRoute(ContainerInterface $container, string $urlBase) {
 | 
					    public function registerRoute(ContainerInterface $container, string $urlBase) {
 | 
				
			||||||
        #$this->registeredRoutes ??= [];
 | 
					        $this->registeredRoutes[$urlBase] ??= [];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) {
 | 
					        $this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container, $urlBase) {
 | 
				
			||||||
            foreach($this->fetchRoutesAttributes() as $attribute) {
 | 
					            foreach(array_reverse($this->fetcher->compile()) 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) {
 | 
				
			||||||
                    #if (! empty($this->registeredRoutes[$attribute->getRoute().$method])) {
 | 
					                    if (! empty($this->registeredRoutes[$urlBase][$attribute->getRoute().$method])) {
 | 
				
			||||||
                    #     continue;
 | 
					                        continue;
 | 
				
			||||||
                    #}
 | 
					                    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    #$this->registeredRoutes[$attribute->getRoute().$method] = true;
 | 
					                    $this->registeredRoutes[$urlBase][$attribute->getRoute().$method] = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $route->map(strtoupper($method), $attribute->getRoute(), function (ServerRequestInterface $request, array $arguments) use (
 | 
					                    $route->map(strtoupper($method), $attribute->getRoute(), function (ServerRequestInterface $request, array $arguments) use (
 | 
				
			||||||
                        $container, $route, $attribute
 | 
					                        $container, $route, $attribute
 | 
				
			||||||
@ -58,40 +57,4 @@ 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);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
				
			|||||||
@ -6,11 +6,9 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        <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>
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user