@@ 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. |
@@ 357-373 (lines=17) @@ | ||
354 | * @param ClassLocatorInterface $locator |
|
355 | * @return $this |
|
356 | */ |
|
357 | protected function locateSources(ClassLocatorInterface $locator) |
|
358 | { |
|
359 | foreach ($locator->getClasses(RecordSource::class) as $class => $definition) { |
|
360 | $reflection = new \ReflectionClass($class); |
|
361 | ||
362 | if ($reflection->isAbstract() || empty($record = $reflection->getConstant('RECORD'))) { |
|
363 | continue; |
|
364 | } |
|
365 | ||
366 | if ($this->hasRecord($record)) { |
|
367 | //Associating source with record |
|
368 | $this->record($record)->setSource($class); |
|
369 | } |
|
370 | } |
|
371 | ||
372 | return $this; |
|
373 | } |
|
374 | ||
375 | /** |
|
376 | * SchemaBuilder will request every located RecordSchema to declare it's schemas and relations. |