Files
michaelschiemer/src/Framework/Database/Events/EntityDeletedEvent.php
Michael Schiemer 55a330b223 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
2025-08-11 20:13:26 +02:00

48 lines
1.1 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Framework\Database\Events;
use App\Framework\Core\ValueObjects\Timestamp;
/**
* Event that is fired when an entity is deleted
*/
final readonly class EntityDeletedEvent
{
public Timestamp $timestamp;
public function __construct(
public object $entity,
public string $entityClass,
public mixed $entityId,
public array $deletedData = [],
?Timestamp $timestamp = null
) {
$this->timestamp = $timestamp ?? Timestamp::now();
}
/**
* Check if this event is for a specific entity class
*/
public function isEntityOfType(string $expectedClass): bool
{
return $this->entityClass === $expectedClass || $this->entity instanceof $expectedClass;
}
/**
* Get event metadata
*/
public function getEventData(): array
{
return [
'event_type' => 'entity_deleted',
'entity_class' => $this->entityClass,
'entity_id' => $this->entityId,
'timestamp' => $this->timestamp->toFloat(),
'deleted_data' => $this->deletedData,
];
}
}