Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make it easier to create non-aggregate root aggregate roots...
- Loading branch information
Showing
1 changed file
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Dflydev\EventSauce\Support\AggregateRoot; | ||
|
||
use EventSauce\EventSourcing\AggregateRoot; | ||
use EventSauce\EventSourcing\AggregateRootId; | ||
use EventSauce\EventSourcing\AggregateRootId as AggregateRootIdType; | ||
use Generator; | ||
|
||
/** | ||
* @template T1 of AggregateRoot | ||
* @template T2 of AggregateRootId | ||
*/ | ||
trait AsNotAnAggregateRootBehavior | ||
{ | ||
public function aggregateRootVersion(): int | ||
{ | ||
throw new \RuntimeException('Aggregate root version is not implemented'); | ||
} | ||
|
||
public function releaseEvents(): array | ||
{ | ||
throw new \RuntimeException('Aggregate root tracks no events'); | ||
} | ||
|
||
public static function reconstituteFromEvents(AggregateRootIdType $aggregateRootId, Generator $events): static | ||
{ | ||
throw new \RuntimeException('Aggregate root cannot be reconstituted from events'); | ||
} | ||
} |