|
@@ 344-356 (lines=13) @@
|
| 341 |
|
*/ |
| 342 |
|
public function loader($relation, array $options = []) |
| 343 |
|
{ |
| 344 |
|
if (($position = strpos($relation, '.')) !== false) { |
| 345 |
|
//Chain of relations provided |
| 346 |
|
$nested = $this->loader(substr($relation, 0, $position), []); |
| 347 |
|
|
| 348 |
|
if (empty($nested) || !$nested instanceof self) { |
| 349 |
|
//todo: Think about the options |
| 350 |
|
throw new LoaderException( |
| 351 |
|
"Only ORM loaders can be used to generate/configure chain of relation loaders." |
| 352 |
|
); |
| 353 |
|
} |
| 354 |
|
|
| 355 |
|
//Recursively (will work only with ORM loaders). |
| 356 |
|
return $nested->loader(substr($relation, $position + 1), $options); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
if (!isset($this->schema[ORM::M_RELATIONS][$relation])) { |
|
@@ 428-439 (lines=12) @@
|
| 425 |
|
//We have to force joining method for full chain |
| 426 |
|
$options['method'] = self::JOIN; |
| 427 |
|
|
| 428 |
|
if (($position = strpos($relation, '.')) !== false) { |
| 429 |
|
//Chain of relations provided |
| 430 |
|
$nested = $this->joiner(substr($relation, 0, $position), []); |
| 431 |
|
if (empty($nested) || !$nested instanceof self) { |
| 432 |
|
//todo: DRY |
| 433 |
|
throw new LoaderException( |
| 434 |
|
"Only ORM loaders can be used to generate/configure chain of relation joiners." |
| 435 |
|
); |
| 436 |
|
} |
| 437 |
|
|
| 438 |
|
//Recursively (will work only with ORM loaders). |
| 439 |
|
return $nested->joiner(substr($relation, $position + 1), $options); |
| 440 |
|
} |
| 441 |
|
|
| 442 |
|
if (!isset($this->schema[ORM::M_RELATIONS][$relation])) { |