@@ 165-186 (lines=22) @@ | ||
162 | * @param ResourceInterface $object |
|
163 | * @return CancellablePromiseInterface |
|
164 | */ |
|
165 | protected function hydrateApplyAnnotations(array $json, ResourceInterface $object): CancellablePromiseInterface |
|
166 | { |
|
167 | $promiseChain = resolve($json); |
|
168 | foreach ($this->annotationHandlers as $annotationClass => $handler) { |
|
169 | $annotation = $this->getAnnotation($object, $annotationClass); |
|
170 | if ($annotation === null) { |
|
171 | continue; |
|
172 | } |
|
173 | ||
174 | $req = [ |
|
175 | 'handler' => $handler, |
|
176 | 'annotation' => $annotation, |
|
177 | 'object' => $object, |
|
178 | ]; |
|
179 | ||
180 | $promiseChain = $promiseChain->then(function (array $json) use ($req) { |
|
181 | return $req['handler']->hydrate($req['annotation'], $json, $req['object']); |
|
182 | }); |
|
183 | } |
|
184 | ||
185 | return $promiseChain; |
|
186 | } |
|
187 | ||
188 | protected function getEmptyOrResource(string $class, array $json): string |
|
189 | { |
|
@@ 255-276 (lines=22) @@ | ||
252 | * @param ResourceInterface $object |
|
253 | * @return CancellablePromiseInterface |
|
254 | */ |
|
255 | protected function extractApplyAnnotations(ResourceInterface $object, array $json): CancellablePromiseInterface |
|
256 | { |
|
257 | $promiseChain = resolve($json); |
|
258 | foreach ($this->annotationHandlers as $annotationClass => $handler) { |
|
259 | $annotation = $this->getAnnotation($object, $annotationClass); |
|
260 | if ($annotation === null) { |
|
261 | continue; |
|
262 | } |
|
263 | ||
264 | $req = [ |
|
265 | 'handler' => $handler, |
|
266 | 'annotation' => $annotation, |
|
267 | 'object' => $object, |
|
268 | ]; |
|
269 | ||
270 | $promiseChain = $promiseChain->then(function (array $json) use ($req) { |
|
271 | return $req['handler']->extract($req['annotation'], $req['object'], $json); |
|
272 | }); |
|
273 | } |
|
274 | ||
275 | return $promiseChain; |
|
276 | } |
|
277 | ||
278 | /** |
|
279 | * @param ResourceInterface $object |