| @@ 259-278 (lines=20) @@ | ||
| 256 | * @param ClassLocatorInterface $locator |
|
| 257 | * @return $this |
|
| 258 | */ |
|
| 259 | protected function locateSources(ClassLocatorInterface $locator) |
|
| 260 | { |
|
| 261 | foreach ($locator->getClasses(DocumentSource::class) as $class => $definition) { |
|
| 262 | $reflection = new \ReflectionClass($class); |
|
| 263 | ||
| 264 | if ( |
|
| 265 | $reflection->isAbstract() |
|
| 266 | || empty($document = $reflection->getConstant('DOCUMENT')) |
|
| 267 | ) { |
|
| 268 | continue; |
|
| 269 | } |
|
| 270 | ||
| 271 | if ($this->hasDocument($document)) { |
|
| 272 | //Associating source with record |
|
| 273 | $this->document($document)->setSource($class); |
|
| 274 | } |
|
| 275 | } |
|
| 276 | ||
| 277 | return $this; |
|
| 278 | } |
|
| 279 | ||
| 280 | /** |
|
| 281 | * Create instances of CollectionSchema associated with found DocumentSchema instances. |
|
| @@ 355-371 (lines=17) @@ | ||
| 352 | * @param ClassLocatorInterface $locator |
|
| 353 | * @return $this |
|
| 354 | */ |
|
| 355 | protected function locateSources(ClassLocatorInterface $locator) |
|
| 356 | { |
|
| 357 | foreach ($locator->getClasses(RecordSource::class) as $class => $definition) { |
|
| 358 | $reflection = new \ReflectionClass($class); |
|
| 359 | ||
| 360 | if ($reflection->isAbstract() || empty($record = $reflection->getConstant('RECORD'))) { |
|
| 361 | continue; |
|
| 362 | } |
|
| 363 | ||
| 364 | if ($this->hasRecord($record)) { |
|
| 365 | //Associating source with record |
|
| 366 | $this->record($record)->setSource($class); |
|
| 367 | } |
|
| 368 | } |
|
| 369 | ||
| 370 | return $this; |
|
| 371 | } |
|
| 372 | ||
| 373 | /** |
|
| 374 | * SchemaBuilder will request every located RecordSchema to declare it's relations. In addition |
|