source/Spiral/ORM/Schemas/SchemaBuilder.php
protected function renderRelations()
    {
        foreach ($this->schemas as $schema) {
            foreach ($schema->getRelations() as $name => $relation) {

                //Source context defines where relation comes from
                $sourceContext = RelationContext::createContent(
                    $schema,
                    $this->requestTable($schema->getTable(), $schema->getDatabase())
                );

                //Target context might only exist if relation points to another record in ORM,
                //in some cases it might point outside of ORM scope
                $targetContext = null;

                if ($this->hasSchema($relation->getTarget())) {
                    $target = $this->getSchema($relation->getTarget());

                    $targetContext = RelationContext::createContent(
                        $target,
                        $this->requestTable($target->getTable(), $target->getDatabase())
                    );
                }

                $this->relations->registerRelation(
                    $this,
                    $relation->withContext($sourceContext, $targetContext)
                );
            }
        }
    }
protected function renderRelations()
    {
        foreach ($this->schemas as $schema) {
            foreach ($schema->getRelations() as $name => $relation) {

                //Source context defines where relation comes from
                $sourceContext = RelationContext::createContent(
                    $schema,
                    $this->requestTable($schema->getTable(), $schema->getDatabase())
                );

                //Target context might only exist if relation points to another record in ORM,
                //in some cases it might point outside of ORM scope
                $targetContext = null;

                if ($this->hasSchema($relation->getTarget())) {
                    $target = $this->getSchema($relation->getTarget());

                    $targetContext = RelationContext::createContent(
                        $target,
                        $this->requestTable($target->getTable(), $target->getDatabase())
                    );
                }

                $this->relations->registerRelation(
                    $this,
                    $relation->withContext($sourceContext, $targetContext)
                );
            }
        }
    }
protected function renderRelations ( ) { foreach ( $ this -> schemas as $ schema ) { foreach ( $ schema -> getRelations ( ) as $ name => $ relation ) { //Source context defines where relation comes from $ sourceContext = RelationContext :: createContent ( $ schema , $ this -> requestTable ( $ schema -> getTable ( ) , $ schema -> getDatabase ( ) ) ) ; //Target context might only exist if relation points to another record in ORM, //in some cases it might point outside of ORM scope $ targetContext = null ; if ( $ this -> hasSchema ( $ relation -> getTarget ( ) ) ) { $ target = $ this -> getSchema ( $ relation -> getTarget ( ) ) ; $ targetContext = RelationContext :: createContent ( $ target , $ this -> requestTable ( $ target -> getTable ( ) , $ target -> getDatabase ( ) ) ) ; } $ this -> relations -> registerRelation ( $ this , $ relation -> withContext ( $ sourceContext , $ targetContext ) ) ; } } }
Walk thought all record schemas, fetch and declare needed relations using relation manager.

@throws SchemaException
@throws DefinitionException
Walk thought all record schemas fetch and declare needed relations using relation manager .