| @@ 196-217 (lines=22) @@ | ||
| 193 | * @param Finder $finder Mapping finder |
|
| 194 | * @return array |
|
| 195 | */ |
|
| 196 | private function loadDoctrineClassMap(Finder $finder) |
|
| 197 | { |
|
| 198 | $classMap = []; |
|
| 199 | foreach ($finder as $file) { |
|
| 200 | $document = new \DOMDocument(); |
|
| 201 | $document->load($file); |
|
| 202 | ||
| 203 | $xpath = new \DOMXPath($document); |
|
| 204 | $xpath->registerNamespace('doctrine', 'http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping'); |
|
| 205 | ||
| 206 | $classMap = array_reduce( |
|
| 207 | iterator_to_array($xpath->query('//*[self::doctrine:document or self::doctrine:embedded-document]')), |
|
| 208 | function (array $classMap, \DOMElement $element) { |
|
| 209 | $classMap[$element->getAttribute('name')] = $element; |
|
| 210 | return $classMap; |
|
| 211 | }, |
|
| 212 | $classMap |
|
| 213 | ); |
|
| 214 | } |
|
| 215 | ||
| 216 | return $classMap; |
|
| 217 | } |
|
| 218 | ||
| 219 | /** |
|
| 220 | * Load serializer class map |
|
| @@ 225-245 (lines=21) @@ | ||
| 222 | * @param Finder $finder Mapping finder |
|
| 223 | * @return array |
|
| 224 | */ |
|
| 225 | private function loadSerializerClassMap(Finder $finder) |
|
| 226 | { |
|
| 227 | $classMap = []; |
|
| 228 | foreach ($finder as $file) { |
|
| 229 | $document = new \DOMDocument(); |
|
| 230 | $document->load($file); |
|
| 231 | ||
| 232 | $xpath = new \DOMXPath($document); |
|
| 233 | ||
| 234 | $classMap = array_reduce( |
|
| 235 | iterator_to_array($xpath->query('//class')), |
|
| 236 | function (array $classMap, \DOMElement $element) { |
|
| 237 | $classMap[$element->getAttribute('name')] = $element; |
|
| 238 | return $classMap; |
|
| 239 | }, |
|
| 240 | $classMap |
|
| 241 | ); |
|
| 242 | } |
|
| 243 | ||
| 244 | return $classMap; |
|
| 245 | } |
|
| 246 | ||
| 247 | /** |
|
| 248 | * Load validation class map |
|
| @@ 253-274 (lines=22) @@ | ||
| 250 | * @param Finder $finder Mapping finder |
|
| 251 | * @return array |
|
| 252 | */ |
|
| 253 | private function loadValidationClassMap(Finder $finder) |
|
| 254 | { |
|
| 255 | $classMap = []; |
|
| 256 | foreach ($finder as $file) { |
|
| 257 | $document = new \DOMDocument(); |
|
| 258 | $document->load($file); |
|
| 259 | ||
| 260 | $xpath = new \DOMXPath($document); |
|
| 261 | $xpath->registerNamespace('constraint', 'http://symfony.com/schema/dic/constraint-mapping'); |
|
| 262 | ||
| 263 | $classMap = array_reduce( |
|
| 264 | iterator_to_array($xpath->query('//constraint:class')), |
|
| 265 | function (array $classMap, \DOMElement $element) { |
|
| 266 | $classMap[$element->getAttribute('name')] = $element; |
|
| 267 | return $classMap; |
|
| 268 | }, |
|
| 269 | $classMap |
|
| 270 | ); |
|
| 271 | } |
|
| 272 | ||
| 273 | return $classMap; |
|
| 274 | } |
|
| 275 | ||
| 276 | /** |
|
| 277 | * Get serializer fields |
|