| @@ 226-247 (lines=22) @@ | ||
| 223 | * @param Finder $finder Mapping finder |
|
| 224 | * @return array |
|
| 225 | */ |
|
| 226 | private function loadDoctrineClassMap(Finder $finder) |
|
| 227 | { |
|
| 228 | $classMap = []; |
|
| 229 | foreach ($finder as $file) { |
|
| 230 | $document = new \DOMDocument(); |
|
| 231 | $document->load($file); |
|
| 232 | ||
| 233 | $xpath = new \DOMXPath($document); |
|
| 234 | $xpath->registerNamespace('doctrine', 'http://doctrine-project.org/schemas/odm/doctrine-mongo-mapping'); |
|
| 235 | ||
| 236 | $classMap = array_reduce( |
|
| 237 | iterator_to_array($xpath->query('//*[self::doctrine:document or self::doctrine:embedded-document]')), |
|
| 238 | function (array $classMap, \DOMElement $element) { |
|
| 239 | $classMap[$element->getAttribute('name')] = $element; |
|
| 240 | return $classMap; |
|
| 241 | }, |
|
| 242 | $classMap |
|
| 243 | ); |
|
| 244 | } |
|
| 245 | ||
| 246 | return $classMap; |
|
| 247 | } |
|
| 248 | ||
| 249 | /** |
|
| 250 | * Load serializer class map |
|
| @@ 255-275 (lines=21) @@ | ||
| 252 | * @param Finder $finder Mapping finder |
|
| 253 | * @return array |
|
| 254 | */ |
|
| 255 | private function loadSerializerClassMap(Finder $finder) |
|
| 256 | { |
|
| 257 | $classMap = []; |
|
| 258 | foreach ($finder as $file) { |
|
| 259 | $document = new \DOMDocument(); |
|
| 260 | $document->load($file); |
|
| 261 | ||
| 262 | $xpath = new \DOMXPath($document); |
|
| 263 | ||
| 264 | $classMap = array_reduce( |
|
| 265 | iterator_to_array($xpath->query('//class')), |
|
| 266 | function (array $classMap, \DOMElement $element) { |
|
| 267 | $classMap[$element->getAttribute('name')] = $element; |
|
| 268 | return $classMap; |
|
| 269 | }, |
|
| 270 | $classMap |
|
| 271 | ); |
|
| 272 | } |
|
| 273 | ||
| 274 | return $classMap; |
|
| 275 | } |
|
| 276 | ||
| 277 | /** |
|
| 278 | * Load schema class map |
|
| @@ 322-343 (lines=22) @@ | ||
| 319 | * @param Finder $finder Mapping finder |
|
| 320 | * @return array |
|
| 321 | */ |
|
| 322 | private function loadValidationClassMap(Finder $finder) |
|
| 323 | { |
|
| 324 | $classMap = []; |
|
| 325 | foreach ($finder as $file) { |
|
| 326 | $document = new \DOMDocument(); |
|
| 327 | $document->load($file); |
|
| 328 | ||
| 329 | $xpath = new \DOMXPath($document); |
|
| 330 | $xpath->registerNamespace('constraint', 'http://symfony.com/schema/dic/constraint-mapping'); |
|
| 331 | ||
| 332 | $classMap = array_reduce( |
|
| 333 | iterator_to_array($xpath->query('//constraint:class')), |
|
| 334 | function (array $classMap, \DOMElement $element) { |
|
| 335 | $classMap[$element->getAttribute('name')] = $element; |
|
| 336 | return $classMap; |
|
| 337 | }, |
|
| 338 | $classMap |
|
| 339 | ); |
|
| 340 | } |
|
| 341 | ||
| 342 | return $classMap; |
|
| 343 | } |
|
| 344 | ||
| 345 | /** |
|
| 346 | * Get serializer fields |
|