#[EventSourcingAggregate] // 1
use WithAggregateVersioning; // 2
#[AggregateIdentifier] // 1
private string $ticketId;
private string $ticketType;
public static function register(RegisterTicket $command) : array
return [new TicketWasRegistered($command->getTicketId(), $command->getTicketType())];
public function close(CloseTicket $command) : array
return [new TicketWasClosed($this->ticketId)];
#[EventSourcingHandler] // 4
public function applyTicketWasRegistered(TicketWasRegistered $event) : void
$this->ticketId = $event->getTicketId();
$this->ticketType = $event->getTicketType();