1 | <?php |
||
13 | trait EventSourced |
||
14 | { |
||
15 | /** |
||
16 | * Collection of events that are not persisted yet |
||
17 | * @var UncommittedEvents |
||
18 | */ |
||
19 | private $uncommittedEvents; |
||
20 | |||
21 | /** |
||
22 | * Determine whether the object's state has changed since the last clearChanges(); |
||
23 | * |
||
24 | * @return bool |
||
25 | */ |
||
26 | public function hasChanges() |
||
30 | |||
31 | /** |
||
32 | * Get all changes to the object since the last the last clearChanges(); |
||
33 | * |
||
34 | * @return UncommittedEvents |
||
35 | */ |
||
36 | public function getChanges() |
||
40 | |||
41 | /** |
||
42 | * Clear all state changes from this object. |
||
43 | * |
||
44 | * @return static |
||
45 | */ |
||
46 | public function clearChanges() |
||
52 | |||
53 | /** |
||
54 | * Register a event happening on the aggregate |
||
55 | * |
||
56 | * @param DomainEvent $event |
||
57 | * @return static |
||
58 | */ |
||
59 | public function recordThat(DomainEvent $event) |
||
72 | |||
73 | abstract protected function bumpVersion(); |
||
74 | |||
75 | /** |
||
76 | * The concrete class should have this method |
||
77 | */ |
||
78 | abstract protected function when(DomainEvent $event); |
||
79 | |||
80 | /** |
||
81 | * The concrete class should have this method |
||
82 | */ |
||
83 | abstract protected function getIdentity(); |
||
84 | } |
||
85 |