source/Spiral/ORM/Entities/RelationMap.php
public function queueRelations(ContextualCommandInterface $parent): ContextualCommandInterface
    {
        if (empty($this->relations)) {
            //No relations exists, nothing to do
            return $parent;
        }

        //We have to execute multiple commands at once
        $transaction = new TransactionalCommand();

        foreach ($this->leadingRelations() as $relation) {
            //Generating commands needed to save given relation prior to parent command
            if ($relation->isLoaded()) {
                $transaction->addCommand($relation->queueCommands($parent));
            }
        }

        //Parent model save operations (true state that this is leading/primary command)
        $transaction->addCommand($parent, true);

        foreach ($this->dependedRelations() as $relation) {
            //Generating commands needed to save relations after parent command being executed
            if ($relation->isLoaded()) {
                $transaction->addCommand($relation->queueCommands($parent));
            }
        }

        return $transaction;
    }
public function queueRelations(ContextualCommandInterface $parent): ContextualCommandInterface
    {
        if (empty($this->relations)) {
            //No relations exists, nothing to do
            return $parent;
        }

        //We have to execute multiple commands at once
        $transaction = new TransactionalCommand();

        foreach ($this->leadingRelations() as $relation) {
            //Generating commands needed to save given relation prior to parent command
            if ($relation->isLoaded()) {
                $transaction->addCommand($relation->queueCommands($parent));
            }
        }

        //Parent model save operations (true state that this is leading/primary command)
        $transaction->addCommand($parent, true);

        foreach ($this->dependedRelations() as $relation) {
            //Generating commands needed to save relations after parent command being executed
            if ($relation->isLoaded()) {
                $transaction->addCommand($relation->queueCommands($parent));
            }
        }

        return $transaction;
    }
public function queueRelations ( ContextualCommandInterface $ parent ) : ContextualCommandInterface { if ( empty ( $ this -> relations ) ) { //No relations exists, nothing to do return $ parent ; } //We have to execute multiple commands at once $ transaction = new TransactionalCommand ( ) ; foreach ( $ this -> leadingRelations ( ) as $ relation ) { //Generating commands needed to save given relation prior to parent command if ( $ relation -> isLoaded ( ) ) { $ transaction -> addCommand ( $ relation -> queueCommands ( $ parent ) ) ; } } //Parent model save operations (true state that this is leading/primary command) $ transaction -> addCommand ( $ parent , true ) ; foreach ( $ this -> dependedRelations ( ) as $ relation ) { //Generating commands needed to save relations after parent command being executed if ( $ relation -> isLoaded ( ) ) { $ transaction -> addCommand ( $ relation -> queueCommands ( $ parent ) ) ; } } return $ transaction ; }
Generate command tree with or without relation to parent command in order to specify update
or insert sequence. Commands might define dependencies between each other in order to extend
FK values.

@param ContextualCommandInterface $parent

@return ContextualCommandInterface
Generate command tree with or without relation to parent command in order to specify update or insert sequence . Commands might define dependencies between each other in order to extend FK values .