<?php

declare(strict_types=1);

namespace App\Framework\EventSourcing\Sagas;

use App\Framework\Attributes\EventHandler as EventHandlerAttribute;
use App\Framework\EventSourcing\DomainEvent;

/**
 * Saga Event Listener
 *
 * Listens to domain events and routes them to interested sagas
 */
#[EventHandlerAttribute]
final readonly class SagaEventListener
{
    public function __construct(
        private SagaManager $sagaManager
    ) {
    }

    /**
     * Handle any domain event and route to sagas
     */
    public function handle(DomainEvent $event): void
    {
        $this->sagaManager->handleEvent($event);
    }
}
