1 | <?php |
||
13 | abstract class AbstractAggregateRoot |
||
14 | { |
||
15 | /** |
||
16 | * @var int |
||
17 | */ |
||
18 | protected $id; |
||
19 | |||
20 | /** |
||
21 | * List of events that occurred. |
||
22 | * |
||
23 | * @var EventInterface[] |
||
24 | */ |
||
25 | private $events = array(); |
||
26 | |||
27 | /** |
||
28 | * @return int |
||
29 | */ |
||
30 | public function getId() |
||
34 | |||
35 | /** |
||
36 | * This allows you to get every events raised by the aggregate and clear the stack. |
||
37 | * It's helpful when you do event sourcing because once an event is raised you may need to do some actions in other |
||
38 | * bounded contexts. So the events is fired once. |
||
39 | * |
||
40 | * @return EventInterface[] |
||
41 | */ |
||
42 | public function pullEvents() |
||
50 | |||
51 | /** |
||
52 | * Used when somebody is trying to modify an Aggregate. |
||
53 | * You should check that the input is good then create an event and call this method. |
||
54 | * |
||
55 | * @param EventInterface $event |
||
56 | */ |
||
57 | protected function apply(EventInterface $event) |
||
62 | |||
63 | /** |
||
64 | * @param EventInterface $event |
||
65 | * |
||
66 | * @throws BadMethodCallException |
||
67 | */ |
||
68 | private function executeEvent(EventInterface $event) |
||
87 | |||
88 | /** |
||
89 | * |
||
90 | */ |
||
91 | private function safelyPopulateEventsWithAggregateId() |
||
99 | } |
||
100 |