1 | <?php |
||
22 | abstract class UserAggregateRoot |
||
23 | { |
||
24 | /** |
||
25 | * Array which contains the domain events. |
||
26 | * |
||
27 | * @var array |
||
28 | */ |
||
29 | private $events = []; |
||
30 | |||
31 | /** |
||
32 | * Clears the events container. |
||
33 | */ |
||
34 | public function eraseEvents() |
||
38 | |||
39 | /** |
||
40 | * Gets the recorded domain events. |
||
41 | * |
||
42 | * @return array |
||
43 | */ |
||
44 | public function events() |
||
48 | |||
49 | /** |
||
50 | * Publishes the domain event. |
||
51 | * |
||
52 | * If the solution needs a singleton based event system, |
||
53 | * this methods will be overwritten. |
||
54 | * |
||
55 | * The recommend way is to record events domains in the aggregate root |
||
56 | * so, by default, this method calls to the "record" method. |
||
57 | * |
||
58 | * @param UserEvent $anEvent The domain event |
||
59 | */ |
||
60 | protected function publish(UserEvent $anEvent) |
||
64 | |||
65 | /** |
||
66 | * Saves the given domain event inside event container. |
||
67 | * |
||
68 | * @param UserEvent $anEvent The domain event |
||
69 | */ |
||
70 | private function record(UserEvent $anEvent) |
||
74 | } |
||
75 |