| 1 | <?php |
||
| 9 | abstract class BaseAggregateRoot implements AggregateRoot |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * @var Event[] |
||
| 13 | */ |
||
| 14 | private $recordedEvents; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * @var AggregateRootId |
||
| 18 | */ |
||
| 19 | private $aggregateRootId; |
||
| 20 | |||
| 21 | 6 | final public function __construct(AggregateRootId $aggregateRootId) |
|
| 26 | |||
| 27 | 2 | public function aggregateRootId(): AggregateRootId |
|
| 31 | |||
| 32 | 2 | protected function recordThat(Event $event) |
|
| 37 | |||
| 38 | /** |
||
| 39 | * @return Event[] |
||
| 40 | */ |
||
| 41 | 6 | public function releaseEvents(): array |
|
| 48 | |||
| 49 | 2 | protected function apply(Event $event) |
|
| 54 | |||
| 55 | /** |
||
| 56 | * @param AggregateRootId $aggregateRootId |
||
| 57 | * @param Generator $events |
||
| 58 | * |
||
| 59 | * @return static |
||
| 60 | */ |
||
| 61 | 6 | public static function reconstituteFromEvents(AggregateRootId $aggregateRootId, Generator $events): AggregateRoot |
|
| 72 | } |