Enable Discovery debug logging for production troubleshooting
- Add DISCOVERY_LOG_LEVEL=debug - Add DISCOVERY_SHOW_PROGRESS=true - Temporary changes for debugging InitializerProcessor fixes on production
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
class AfterEmitResponse
|
||||
final readonly class AfterEmitResponse
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
class AfterHandleRequest
|
||||
final readonly class AfterHandleRequest
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
@@ -10,5 +11,6 @@ final readonly class ApplicationBooted
|
||||
public string $environment,
|
||||
public string $version = 'dev',
|
||||
public \DateTimeImmutable $occurredAt = new \DateTimeImmutable()
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
class BeforeEmitResponse
|
||||
final readonly class BeforeEmitResponse
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
class BeforeHandleRequest
|
||||
final readonly class BeforeHandleRequest
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
@@ -10,5 +11,6 @@ final readonly class ErrorOccurred
|
||||
public string $context = '',
|
||||
public ?string $requestId = null,
|
||||
public \DateTimeImmutable $occurredAt = new \DateTimeImmutable()
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
@@ -8,7 +9,7 @@ use App\Framework\DI\DefaultContainer;
|
||||
/**
|
||||
* Führt abschließende Konfigurationen für das Event-System durch
|
||||
*/
|
||||
final class EventCompilerPass
|
||||
final readonly class EventCompilerPass
|
||||
{
|
||||
/**
|
||||
* Richtet zusätzliche Event-Konfigurationen ein
|
||||
|
||||
@@ -1,15 +1,17 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
use App\Framework\DI\Container;
|
||||
use App\Framework\DI\DefaultContainer;
|
||||
|
||||
/**
|
||||
* Der EventDispatcher ist verantwortlich für die Verarbeitung von Events
|
||||
* und das Aufrufen der entsprechenden Event-Handler
|
||||
*/
|
||||
final class EventDispatcher
|
||||
final class EventDispatcher implements EventDispatcherInterface
|
||||
{
|
||||
/** @var array<string, array> Mapping von Event-Typen zu Handlern */
|
||||
private array $handlers = [];
|
||||
@@ -22,9 +24,10 @@ final class EventDispatcher
|
||||
* @param array|null $eventHandlers Array mit Event-Handlern aus der Autodiscovery
|
||||
*/
|
||||
public function __construct(
|
||||
private readonly DefaultContainer $container,
|
||||
private readonly Container $container,
|
||||
private readonly ?array $eventHandlers = null
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialisiert den EventDispatcher mit den Event-Handlern
|
||||
@@ -149,8 +152,8 @@ final class EventDispatcher
|
||||
'callable' => $handler,
|
||||
'attribute_data' => [
|
||||
'priority' => $priority ?? 0,
|
||||
'stopPropagation' => $stopPropagation
|
||||
]
|
||||
'stopPropagation' => $stopPropagation,
|
||||
],
|
||||
|
||||
];
|
||||
|
||||
@@ -177,12 +180,12 @@ final class EventDispatcher
|
||||
{
|
||||
$this->initialize();
|
||||
|
||||
if (isset($this->handlers[$eventClass]) && !empty($this->handlers[$eventClass])) {
|
||||
if (isset($this->handlers[$eventClass]) && ! empty($this->handlers[$eventClass])) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Prüfen auf Handler für Basisklassen/Interfaces
|
||||
return array_any(array_keys($this->handlers), fn($handledEventClass) => is_subclass_of($eventClass, $handledEventClass));
|
||||
return array_any(array_keys($this->handlers), fn ($handledEventClass) => is_subclass_of($eventClass, $handledEventClass));
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
use App\Framework\DI\Container;
|
||||
use App\Framework\DI\Initializer;
|
||||
use App\Framework\Discovery\Results\DiscoveryResults;
|
||||
use App\Framework\Discovery\Results\DiscoveryRegistry;
|
||||
|
||||
final readonly class EventDispatcherInitializer
|
||||
{
|
||||
public function __construct(
|
||||
private Container $container,
|
||||
private DiscoveryResults $results
|
||||
){}
|
||||
private DiscoveryRegistry $results
|
||||
) {
|
||||
}
|
||||
|
||||
#[Initializer]
|
||||
public function __invoke(): EventDispatcher
|
||||
{
|
||||
return new EventDispatcher($this->container, $this->results->get(OnEvent::class));
|
||||
$eventResults = $this->results->attributes->get(OnEvent::class);
|
||||
|
||||
$events = [];
|
||||
foreach ($eventResults as $discoveredAttribute) {
|
||||
if ($discoveredAttribute->additionalData) {
|
||||
$events[] = $discoveredAttribute->additionalData;
|
||||
}
|
||||
}
|
||||
|
||||
return new EventDispatcher($this->container, $events);
|
||||
}
|
||||
}
|
||||
|
||||
16
src/Framework/Core/Events/EventDispatcherInterface.php
Normal file
16
src/Framework/Core/Events/EventDispatcherInterface.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
/**
|
||||
* Interface für Event Dispatcher
|
||||
*/
|
||||
interface EventDispatcherInterface
|
||||
{
|
||||
/**
|
||||
* Dispatcht ein Event an alle registrierten Handler
|
||||
*/
|
||||
public function dispatch(object $event): array;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
|
||||
use App\Framework\Core\AttributeMapper;
|
||||
use ReflectionClass;
|
||||
use ReflectionMethod;
|
||||
use App\Framework\Reflection\WrappedReflectionClass;
|
||||
use App\Framework\Reflection\WrappedReflectionMethod;
|
||||
|
||||
/**
|
||||
* Mapper für das OnEvent-Attribut
|
||||
@@ -22,14 +23,10 @@ final class EventHandlerMapper implements AttributeMapper
|
||||
|
||||
/**
|
||||
* Implementiert die map-Methode aus dem AttributeMapper-Interface
|
||||
*
|
||||
* @param object $reflectionTarget Das Reflektionsobjekt (ReflectionClass|ReflectionMethod)
|
||||
* @param object $attributeInstance Die Attributinstanz
|
||||
* @return array|null Die Attributdaten oder null, wenn nicht verarbeitet werden kann
|
||||
*/
|
||||
public function map(object $reflectionTarget, object $attributeInstance): ?array
|
||||
public function map(WrappedReflectionClass|WrappedReflectionMethod $reflectionTarget, object $attributeInstance): ?array
|
||||
{
|
||||
if (!($reflectionTarget instanceof ReflectionMethod)) {
|
||||
if (! ($reflectionTarget instanceof WrappedReflectionMethod)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -41,7 +38,7 @@ final class EventHandlerMapper implements AttributeMapper
|
||||
}
|
||||
|
||||
$eventType = $parameters[0]->getType();
|
||||
if (!$eventType || $eventType->isBuiltin()) {
|
||||
if (! $eventType || $eventType->isBuiltin()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -54,7 +51,7 @@ final class EventHandlerMapper implements AttributeMapper
|
||||
#'reflection' => $reflectionTarget,
|
||||
'attribute_data' => [
|
||||
'priority' => $attributeInstance->priority ?? 0,
|
||||
'stopPropagation' => $attributeInstance->stopPropagation ?? false
|
||||
'stopPropagation' => $attributeInstance->stopPropagation ?? false,
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
@@ -20,5 +21,6 @@ final class OnEvent
|
||||
public function __construct(
|
||||
public readonly ?int $priority = null,
|
||||
public readonly bool $stopPropagation = false
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Framework\Core\Events;
|
||||
@@ -14,5 +15,6 @@ final readonly class UserRegistered
|
||||
public string $username,
|
||||
public \DateTimeImmutable $registeredAt = new \DateTimeImmutable(),
|
||||
public \DateTimeImmutable $occurredAt = new \DateTimeImmutable()
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user