@@ 83-107 (lines=25) @@ | ||
80 | * @param string $streamId |
|
81 | * @return EventStreamInterface |
|
82 | */ |
|
83 | public function readFullStream($streamId) |
|
84 | { |
|
85 | $stmt = $this->connection->prepare( |
|
86 | 'SELECT * |
|
87 | FROM events |
|
88 | WHERE stream_id = :streamId' |
|
89 | ); |
|
90 | $stmt->bindValue(':streamId', $streamId); |
|
91 | $stmt->execute(); |
|
92 | $results = $stmt->fetchAll(); |
|
93 | ||
94 | $storedEvents = array_map(function($result) { |
|
95 | return new StoredEvent( |
|
96 | $result['id'], |
|
97 | $result['stream_id'], |
|
98 | $result['type'], |
|
99 | $result['event'], |
|
100 | $result['metadata'], |
|
101 | new \DateTimeImmutable($result['occurred_on']), |
|
102 | Version::fromString($result['version']) |
|
103 | ); |
|
104 | }, $results); |
|
105 | ||
106 | return $this->domainEventStreamFromStoredEvents($storedEvents); |
|
107 | } |
|
108 | ||
109 | /** |
|
110 | * @return EventStreamInterface[] |
|
@@ 130-156 (lines=27) @@ | ||
127 | * @param Version $version |
|
128 | * @return EventStreamInterface |
|
129 | */ |
|
130 | protected function readStoredEventsOfTypeAndVersion($type, $version) |
|
131 | { |
|
132 | $stmt = $this->connection->prepare( |
|
133 | 'SELECT * |
|
134 | FROM events |
|
135 | WHERE type = :type |
|
136 | AND version = :version' |
|
137 | ); |
|
138 | $stmt->bindValue(':type', $type); |
|
139 | $stmt->bindValue(':version', $version); |
|
140 | $stmt->execute(); |
|
141 | $results = $stmt->fetchAll(); |
|
142 | ||
143 | $storedEvents = array_map(function($result) { |
|
144 | return new StoredEvent( |
|
145 | $result['id'], |
|
146 | $result['stream_id'], |
|
147 | $result['type'], |
|
148 | $result['event'], |
|
149 | $result['metadata'], |
|
150 | new \DateTimeImmutable($result['occurred_on']), |
|
151 | Version::fromString($result['version']) |
|
152 | ); |
|
153 | }, $results); |
|
154 | ||
155 | return new EventStream($storedEvents); |
|
156 | } |
|
157 | ||
158 | /** |
|
159 | * @param string $streamId |
@@ 84-108 (lines=25) @@ | ||
81 | * @param string $streamId |
|
82 | * @return EventStreamInterface |
|
83 | */ |
|
84 | public function readFullStream($streamId) |
|
85 | { |
|
86 | $stmt = $this->connection->prepare( |
|
87 | 'SELECT * |
|
88 | FROM events |
|
89 | WHERE stream_id = :streamId' |
|
90 | ); |
|
91 | $stmt->bindValue(':streamId', $streamId); |
|
92 | $stmt->execute(); |
|
93 | $results = $stmt->fetchAll(); |
|
94 | ||
95 | $storedEvents = array_map(function($event) { |
|
96 | return new StoredEvent( |
|
97 | $event['id'], |
|
98 | $event['stream_id'], |
|
99 | $event['type'], |
|
100 | $event['event'], |
|
101 | $event['metadata'], |
|
102 | new \DateTimeImmutable($event['occurred_on']), |
|
103 | Version::fromString($event['version']) |
|
104 | ); |
|
105 | }, $results); |
|
106 | ||
107 | return $this->domainEventStreamFromStoredEvents($storedEvents); |
|
108 | } |
|
109 | ||
110 | /** |
|
111 | * @return EventStreamInterface[] |
|
@@ 199-225 (lines=27) @@ | ||
196 | * @param Version $version |
|
197 | * @return EventStreamInterface |
|
198 | */ |
|
199 | protected function readStoredEventsOfTypeAndVersion($type, $version) |
|
200 | { |
|
201 | $stmt = $this->connection->prepare( |
|
202 | 'SELECT * |
|
203 | FROM events |
|
204 | WHERE type = :type |
|
205 | AND version = :version' |
|
206 | ); |
|
207 | $stmt->bindValue(':type', $type); |
|
208 | $stmt->bindValue(':version', $version); |
|
209 | $stmt->execute(); |
|
210 | $results = $stmt->fetchAll(); |
|
211 | ||
212 | $storedEvents = array_map(function($result) { |
|
213 | return new StoredEvent( |
|
214 | $result['id'], |
|
215 | $result['stream_id'], |
|
216 | $result['type'], |
|
217 | $result['event'], |
|
218 | $result['metadata'], |
|
219 | new \DateTimeImmutable($result['occurred_on']), |
|
220 | Version::fromString($result['version']) |
|
221 | ); |
|
222 | }, $results); |
|
223 | ||
224 | return new EventStream($storedEvents); |
|
225 | } |
|
226 | ||
227 | public function initialize() |
|
228 | { |