File "AggregateRootCommandHandler.php"
Full Path: /var/www/html/back/vendor/spatie/laravel-event-sourcing/src/Commands/AggregateRootCommandHandler.php
File size: 577 bytes
MIME-type: text/x-php
Charset: utf-8
<?php
namespace Spatie\EventSourcing\Commands;
class AggregateRootCommandHandler
{
public function __construct(
private string $aggregateRootClass,
private string $aggregateUuid,
) {
}
public function __invoke(object $command): void
{
/** @var \Spatie\EventSourcing\AggregateRoots\AggregateRoot|string $aggregateRootClass */
$aggregateRootClass = $this->aggregateRootClass;
$aggregateRoot = $aggregateRootClass::retrieve($this->aggregateUuid);
$aggregateRoot->handleCommand($command)->persist();
}
}