This commit is contained in:
parent
28491fd4ea
commit
23d37db8f6
16 changed files with 23 additions and 38 deletions
|
@ -14,7 +14,7 @@ use function assert;
|
|||
|
||||
require_once __DIR__ . '/../vendor/autoload.php';
|
||||
$cached = false;
|
||||
$container = (new ContainerBuilder)->addDefinitions(
|
||||
$container = (new ContainerBuilder())->addDefinitions(
|
||||
[
|
||||
Finder::class => static fn(): Finder => new Finder(__DIR__, [], $cached),
|
||||
Dispatcher::class => static fn(DispatcherFactory $f): Dispatcher
|
||||
|
|
|
@ -11,8 +11,7 @@ final readonly class Lol
|
|||
{
|
||||
public function __construct(
|
||||
private Dispatcher $dispatcher
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
#[AsHandler(HttpMethod::GET, '/')]
|
||||
public function lol(): void
|
||||
|
|
|
@ -14,6 +14,5 @@ final readonly class AsListener
|
|||
public function __construct(
|
||||
public string $eventClass,
|
||||
public int $priority = 0
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
@ -15,8 +15,7 @@ final class Dispatcher
|
|||
public function __construct(
|
||||
private readonly InvokerInterface $invoker,
|
||||
private array $listeners = [],
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function addListener(Listener $listener): void
|
||||
{
|
||||
|
|
|
@ -18,8 +18,7 @@ final readonly class DispatcherFactory
|
|||
public function __construct(
|
||||
private Finder $finder,
|
||||
private InvokerInterface $invoker,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function getDispatcher(bool $cached = false): Dispatcher
|
||||
{
|
||||
|
|
|
@ -15,6 +15,5 @@ final readonly class Listener
|
|||
public int $priority,
|
||||
public string $listenerClass,
|
||||
public string $listenerMethod,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ final class Finder
|
|||
private readonly string $path,
|
||||
private array $classNames = [],
|
||||
private readonly bool $cached = false,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
/**
|
||||
* @return Listener[]
|
||||
|
|
|
@ -12,8 +12,7 @@ class HttpKernel
|
|||
{
|
||||
public function __construct(
|
||||
private readonly Dispatcher $dispatcher
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
public function handle(Request $request): Response
|
||||
{
|
||||
|
|
|
@ -13,6 +13,5 @@ final readonly class AsHandler
|
|||
public function __construct(
|
||||
public HttpMethod $method,
|
||||
public string $path
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,5 @@ final readonly class Handler
|
|||
public string $path,
|
||||
public string $handlerClass,
|
||||
public string $handlerMethod,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,5 @@ final class RequestEvent extends GenericEvent
|
|||
public Request $request,
|
||||
public Response|null $response = null,
|
||||
public Handler|null $handler = null,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
@ -9,8 +9,7 @@ final readonly class AttributeRouteCollector
|
|||
{
|
||||
public function __construct(
|
||||
private Finder $finder
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
#[AsListener(CollectRoutes::class)]
|
||||
public function collect(CollectRoutes $event): void
|
||||
|
|
|
@ -14,6 +14,5 @@ final class CollectRoutes extends GenericEvent
|
|||
|
||||
public function __construct(
|
||||
public readonly bool $cached = false
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ final readonly class HandlerCaller
|
|||
{
|
||||
public function __construct(
|
||||
private InvokerInterface $invoker
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
#[AsListener(RequestEvent::class, -50)]
|
||||
public function callHandler(RequestEvent $event): void
|
||||
|
|
|
@ -21,8 +21,7 @@ final readonly class HandlerResolver
|
|||
public function __construct(
|
||||
private Dispatcher $dispatcher,
|
||||
private bool $cached = false,
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
|
||||
#[AsListener(RequestEvent::class, -90)]
|
||||
public function resolveHandler(RequestEvent $event): void
|
||||
|
|
|
@ -8,6 +8,5 @@ final class LauschEvent extends GenericEvent
|
|||
{
|
||||
public function __construct(
|
||||
public string $message
|
||||
) {
|
||||
}
|
||||
) {}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue