1 | <?php |
||
26 | abstract class AbstractAggregateRoot implements AggregateRoot |
||
27 | { |
||
28 | use AggregateBehaviour, EventBehaviour; |
||
29 | |||
30 | /** |
||
31 | * @var AggregateEvent[] |
||
32 | */ |
||
33 | private $recordedAggregateEvents = []; |
||
34 | |||
35 | /** |
||
36 | * Prevent aggregate root direct instantiation. |
||
37 | */ |
||
38 | final protected function __construct() |
||
42 | |||
43 | /** |
||
44 | * Set aggregate identity. |
||
45 | * |
||
46 | * @param Identity $identity |
||
47 | */ |
||
48 | final protected function setIdentity(Identity $identity): void |
||
52 | |||
53 | /** |
||
54 | * {@inheritdoc} |
||
55 | */ |
||
56 | final public static function reconstituteFromAggregateEvents(AggregateEventCollection $events): self |
||
63 | |||
64 | /** |
||
65 | * {@inheritdoc} |
||
66 | * |
||
67 | * @throws AggregateException |
||
68 | */ |
||
69 | final public function replayAggregateEvents(AggregateEventCollection $events): void |
||
77 | |||
78 | /** |
||
79 | * Record aggregate event. |
||
80 | * |
||
81 | * @param AggregateEvent $event |
||
82 | * |
||
83 | * @throws AggregateException |
||
84 | */ |
||
85 | final protected function recordAggregateEvent(AggregateEvent $event): void |
||
93 | |||
94 | /** |
||
95 | * Apply aggregate event. |
||
96 | * |
||
97 | * @param AggregateEvent $event |
||
98 | * |
||
99 | * @throws AggregateException |
||
100 | */ |
||
101 | protected function applyAggregateEvent(AggregateEvent $event): void |
||
116 | |||
117 | /** |
||
118 | * {@inheritdoc} |
||
119 | */ |
||
120 | final public function getRecordedAggregateEvents(): AggregateEventCollection |
||
124 | |||
125 | /** |
||
126 | * {@inheritdoc} |
||
127 | */ |
||
128 | final public function clearRecordedAggregateEvents(): void |
||
132 | |||
133 | /** |
||
134 | * {@inheritdoc} |
||
135 | */ |
||
136 | final public function collectRecordedAggregateEvents(): AggregateEventCollection |
||
144 | } |
||
145 |