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) |
|
87 | |||
88 | /** |
||
89 | * @param string $id |
||
90 | * @return EventSourcedAggregateRootInterface |
||
91 | */ |
||
92 | 2 | public function findById($id) |
|
111 | |||
112 | /** |
||
113 | * @param string $id |
||
114 | * @param int $version |
||
115 | * @return EventSourcedAggregateRootInterface |
||
116 | */ |
||
117 | 4 | public function findByIdAndVersion($id, $version) |
|
144 | |||
145 | /** |
||
146 | * @param string $id |
||
147 | * @param \DateTimeImmutable $datetime |
||
148 | * @return EventSourcedAggregateRootInterface |
||
149 | */ |
||
150 | 2 | public function findByIdAndDatetime($id, $datetime) |
|
156 | |||
157 | /** |
||
158 | * @param EventSourcedAggregateRootInterface $aggregate |
||
159 | * @return string |
||
160 | */ |
||
161 | 6 | private function streamIdFromAggregate($aggregate) |
|
167 | |||
168 | /** |
||
169 | * @param string $aggregateId |
||
170 | * @return string |
||
171 | */ |
||
172 | 12 | protected function streamIdFromAggregateId($aggregateId) |
|
176 | } |
||
177 |