1 | <?php |
||
8 | class EventSourcedAggregateRepository |
||
9 | { |
||
10 | /** |
||
11 | * @var EventStoreInterface |
||
12 | */ |
||
13 | private $eventStore; |
||
14 | |||
15 | /** |
||
16 | * @var SnapshotStoreInterface |
||
17 | */ |
||
18 | private $snapshotStore; |
||
19 | |||
20 | /** |
||
21 | * @var AggregateReconstructor |
||
22 | */ |
||
23 | private $aggregateReconstructor; |
||
24 | |||
25 | /** |
||
26 | * @var string |
||
27 | */ |
||
28 | private $aggregateClass; |
||
29 | |||
30 | /** |
||
31 | * @var AggregateIdExtractorInterface |
||
32 | */ |
||
33 | private $aggregateIdExtractor; |
||
34 | |||
35 | /** |
||
36 | * @param EventStoreInterface $eventStore |
||
37 | * @param SnapshotStoreInterface $snapshotStore |
||
38 | * @param AggregateReconstructor $aggregateReconstructor |
||
39 | * @param AggregateIdExtractorInterface $aggregateIdExtractor |
||
40 | * @param string $aggregateClass |
||
41 | */ |
||
42 | 14 | public function __construct( |
|
55 | |||
56 | /** |
||
57 | * @param EventSourcedAggregateRootInterface $aggregate |
||
58 | */ |
||
59 | 8 | public function save($aggregate) |
|
69 | |||
70 | /** |
||
71 | * @param $aggregate |
||
72 | */ |
||
73 | 8 | private function assertValidAggregate($aggregate) |
|
81 | |||
82 | /** |
||
83 | * @param string $id |
||
84 | * @return EventSourcedAggregateRootInterface |
||
85 | */ |
||
86 | 2 | public function findById($id) |
|
105 | |||
106 | /** |
||
107 | * @param string $id |
||
108 | * @param int $version |
||
109 | * @return EventSourcedAggregateRootInterface |
||
110 | */ |
||
111 | 4 | public function findByIdAndVersion($id, $version) |
|
138 | |||
139 | /** |
||
140 | * @param string $id |
||
141 | * @param \DateTimeImmutable $datetime |
||
142 | * @return EventSourcedAggregateRootInterface |
||
143 | */ |
||
144 | 2 | public function findByIdAndDatetime($id, $datetime) |
|
150 | |||
151 | /** |
||
152 | * @param EventSourcedAggregateRootInterface $aggregate |
||
153 | * @return string |
||
154 | */ |
||
155 | 6 | private function streamIdFromAggregate($aggregate) |
|
161 | |||
162 | /** |
||
163 | * @param string $aggregateId |
||
164 | * @return string |
||
165 | */ |
||
166 | 12 | protected function streamIdFromAggregateId($aggregateId) |
|
170 | } |
||
171 |