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