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