source/Spiral/ORM/Schemas/RelationBuilder.php
public function registerRelation(SchemaBuilder $builder, RelationDefinition $definition)
    {
        if (!$this->config->hasRelation($definition->getType())) {
            throw new DefinitionException(sprintf(
                "Undefined relation type '%s' in '%s'.'%s'",
                $definition->getType(),
                $definition->sourceContext()->getClass(),
                $definition->getName()
            ));
        }

        if ($definition->isLateBinded()) {
            /**
             * Late binded relations locate their parent based on all existed records.
             */
            $definition = $this->locateOuter($builder, $definition);
        }

        $class = $this->config->relationClass(
            $definition->getType(),
            RelationsConfig::SCHEMA_CLASS
        );

        //Creating relation schema
        $relation = $this->factory->make($class, compact('definition'));

        $this->relations[] = $relation;
    }
public function registerRelation(SchemaBuilder $builder, RelationDefinition $definition)
    {
        if (!$this->config->hasRelation($definition->getType())) {
            throw new DefinitionException(sprintf(
                "Undefined relation type '%s' in '%s'.'%s'",
                $definition->getType(),
                $definition->sourceContext()->getClass(),
                $definition->getName()
            ));
        }

        if ($definition->isLateBinded()) {
            /**
             * Late binded relations locate their parent based on all existed records.
             */
            $definition = $this->locateOuter($builder, $definition);
        }

        $class = $this->config->relationClass(
            $definition->getType(),
            RelationsConfig::SCHEMA_CLASS
        );

        //Creating relation schema
        $relation = $this->factory->make($class, compact('definition'));

        $this->relations[] = $relation;
    }
public function registerRelation ( SchemaBuilder $ builder , RelationDefinition $ definition ) { if ( ! $ this -> config -> hasRelation ( $ definition -> getType ( ) ) ) { throw new DefinitionException ( sprintf ( "Undefined relation type '%s' in '%s'.'%s'" , $ definition -> getType ( ) , $ definition -> sourceContext ( ) -> getClass ( ) , $ definition -> getName ( ) ) ) ; } if ( $ definition -> isLateBinded ( ) ) { /**
             * Late binded relations locate their parent based on all existed records.
             */ $ definition = $ this -> locateOuter ( $ builder , $ definition ) ; } $ class = $ this -> config -> relationClass ( $ definition -> getType ( ) , RelationsConfig :: SCHEMA_CLASS ) ; //Creating relation schema $ relation = $ this -> factory -> make ( $ class , compact ( 'definition' ) ) ; $ this -> relations [ ] = $ relation ; }
Registering new relation definition. At this moment function would not check if relation is
unique and will redeclare it.

@param SchemaBuilder      $builder
@param RelationDefinition $definition Relation options (definition).

@throws DefinitionException
Registering new relation definition . At this moment function would not check if relation is unique and will redeclare it .