1 | <?php |
||
13 | abstract class EventSourcedRepository |
||
14 | { |
||
15 | /** @var EventStore */ |
||
16 | private $eventStore; |
||
17 | |||
18 | /** @var EventBus */ |
||
19 | private $eventBus; |
||
20 | |||
21 | |||
22 | /** |
||
23 | * EventSourcedRepository constructor. |
||
24 | * @param EventStore $eventStore |
||
25 | * @param EventBus $eventBus |
||
26 | */ |
||
27 | 6 | public function __construct(EventStore $eventStore, EventBus $eventBus) |
|
32 | |||
33 | |||
34 | /** |
||
35 | * @return string |
||
36 | */ |
||
37 | abstract protected function getPrefix(); |
||
38 | |||
39 | /** |
||
40 | * @return string |
||
41 | */ |
||
42 | abstract protected function getAggregateType(); |
||
43 | |||
44 | /** |
||
45 | * @param string $id |
||
46 | * @return AggregateRootInterface |
||
47 | * @throws \SmoothPhp\EventStore\EventStreamNotFound |
||
48 | 3 | */ |
|
49 | public function load($id) |
||
59 | |||
60 | /** |
||
61 | * @param AggregateRootInterface $aggregate |
||
62 | * @return void |
||
63 | 3 | */ |
|
64 | public function save(AggregateRootInterface $aggregate) |
||
68 | |||
69 | 3 | /** |
|
70 | 3 | * @param AggregateRootInterface $aggregate |
|
71 | * @return void |
||
72 | */ |
||
73 | public function saveWithoutPlayheadCheck(AggregateRootInterface $aggregate) |
||
77 | |||
78 | /** |
||
79 | * @param AggregateRootInterface $aggregate |
||
80 | * @param bool $ignorePlayhead |
||
81 | */ |
||
82 | private function saveAggregate(AggregateRootInterface $aggregate,bool $ignorePlayhead = false) |
||
90 | } |