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 | 12 | public function __construct( |
|
55 | |||
56 | /** |
||
57 | * @param EventSourcedAggregateRootInterface $aggregate |
||
58 | */ |
||
59 | 3 | public function add($aggregate) |
|
67 | |||
68 | /** |
||
69 | * @param EventSourcedAggregateRootInterface $aggregate |
||
70 | */ |
||
71 | 3 | public function save($aggregate) |
|
80 | |||
81 | /** |
||
82 | * @param string $id |
||
83 | * @return EventSourcedAggregateRootInterface |
||
84 | */ |
||
85 | 2 | public function findById($id) |
|
104 | |||
105 | /** |
||
106 | * @param string $id |
||
107 | * @param int $version |
||
108 | * @return EventSourcedAggregateRootInterface |
||
109 | */ |
||
110 | 4 | public function findByIdAndVersion($id, $version) |
|
137 | |||
138 | /** |
||
139 | * @param string $id |
||
140 | * @param \DateTimeImmutable $datetime |
||
141 | * @return EventSourcedAggregateRootInterface |
||
142 | */ |
||
143 | 2 | public function findByIdAndDatetime($id, $datetime) |
|
149 | |||
150 | /** |
||
151 | * @param EventSourcedAggregateRootInterface $aggregate |
||
152 | * @return string |
||
153 | */ |
||
154 | 6 | private function streamIdFromAggregate($aggregate) |
|
160 | |||
161 | /** |
||
162 | * @param string $aggregateId |
||
163 | * @return string |
||
164 | */ |
||
165 | 12 | protected function streamIdFromAggregateId($aggregateId) |
|
169 | } |
||
170 |