| @@ 91-108 (lines=18) @@ | ||
| 88 | * @param array $json | |
| 89 | * @return array | |
| 90 | */ | |
| 91 | protected function hydrateCollectionResources(ResourceInterface $object, array $json) | |
| 92 |     { | |
| 93 | $annotation = $this->getAnnotation($object, Collection::class); | |
| 94 | ||
| 95 |         if (!($annotation instanceof Collection)) { | |
| 96 | return $json; | |
| 97 | } | |
| 98 | ||
| 99 |         foreach ($annotation->properties() as $property) { | |
| 100 | $array = $json[$property]; | |
| 101 | $json[$property] = []; | |
| 102 |             foreach ($array as $resource) { | |
| 103 | $json[$property][] = $this->hydrate($annotation->get($property), $resource); | |
| 104 | } | |
| 105 | } | |
| 106 | ||
| 107 | return $json; | |
| 108 | } | |
| 109 | ||
| 110 | /** | |
| 111 | * @param string $class | |
| @@ 160-177 (lines=18) @@ | ||
| 157 | * @param ResourceInterface $object | |
| 158 | * @return array | |
| 159 | */ | |
| 160 | protected function extractCollectionResources(array $json, ResourceInterface $object) | |
| 161 |     { | |
| 162 | $annotation = $this->getAnnotation($object, Collection::class); | |
| 163 | ||
| 164 |         if (!($annotation instanceof Collection)) { | |
| 165 | return $json; | |
| 166 | } | |
| 167 | ||
| 168 |         foreach ($annotation->properties() as $property) { | |
| 169 | $array = $json[$property]; | |
| 170 | $json[$property] = []; | |
| 171 |             foreach ($array as $resource) { | |
| 172 | $json[$property][] = $this->extract($annotation->get($property), $resource); | |
| 173 | } | |
| 174 | } | |
| 175 | ||
| 176 | return $json; | |
| 177 | } | |
| 178 | ||
| 179 | /** | |
| 180 | * @param ResourceInterface $object | |