source/Spiral/ORM/Entities/Relations/HasOneRelation.php
private function queueRelated(ContextualCommandInterface $parentCommand): CommandInterface
    {
        if (empty($this->instance)) {
            return new NullCommand();
        }

        //Related entity store command
        $innerCommand = $this->instance->queueStore(true);

        //Inversed version of BelongsTo
        if (!$this->isSynced($this->parent, $this->instance)) {
            //Syncing FKs after primary command been executed
            $parentCommand->onExecute(function ($outerCommand) use ($innerCommand) {
                $innerCommand->addContext(
                    $this->key(Record::OUTER_KEY),
                    $this->lookupKey(Record::INNER_KEY, $this->parent, $outerCommand)
                );

                if (!empty($morphKey = $this->key(Record::MORPH_KEY))) {
                    //HasOne relation support additional morph key
                    $innerCommand->addContext(
                        $this->key(Record::MORPH_KEY),
                        $this->orm->define(get_class($this->parent), ORMInterface::R_ROLE_NAME)
                    );
                }
            });
        }

        return $innerCommand;
    }
private function queueRelated(ContextualCommandInterface $parentCommand): CommandInterface
    {
        if (empty($this->instance)) {
            return new NullCommand();
        }

        //Related entity store command
        $innerCommand = $this->instance->queueStore(true);

        //Inversed version of BelongsTo
        if (!$this->isSynced($this->parent, $this->instance)) {
            //Syncing FKs after primary command been executed
            $parentCommand->onExecute(function ($outerCommand) use ($innerCommand) {
                $innerCommand->addContext(
                    $this->key(Record::OUTER_KEY),
                    $this->lookupKey(Record::INNER_KEY, $this->parent, $outerCommand)
                );

                if (!empty($morphKey = $this->key(Record::MORPH_KEY))) {
                    //HasOne relation support additional morph key
                    $innerCommand->addContext(
                        $this->key(Record::MORPH_KEY),
                        $this->orm->define(get_class($this->parent), ORMInterface::R_ROLE_NAME)
                    );
                }
            });
        }

        return $innerCommand;
    }
private function queueRelated ( ContextualCommandInterface $ parentCommand ) : CommandInterface { if ( empty ( $ this -> instance ) ) { return new NullCommand ( ) ; } //Related entity store command $ innerCommand = $ this -> instance -> queueStore ( true ) ; //Inversed version of BelongsTo if ( ! $ this -> isSynced ( $ this -> parent , $ this -> instance ) ) { //Syncing FKs after primary command been executed $ parentCommand -> onExecute ( function ( $ outerCommand ) use ( $ innerCommand ) { $ innerCommand -> addContext ( $ this -> key ( Record :: OUTER_KEY ) , $ this -> lookupKey ( Record :: INNER_KEY , $ this -> parent , $ outerCommand ) ) ; if ( ! empty ( $ morphKey = $ this -> key ( Record :: MORPH_KEY ) ) ) { //HasOne relation support additional morph key $ innerCommand -> addContext ( $ this -> key ( Record :: MORPH_KEY ) , $ this -> orm -> define ( get_class ( $ this -> parent ) , ORMInterface :: R_ROLE_NAME ) ) ; } } ) ; } return $ innerCommand ; }
Store related instance.

@param ContextualCommandInterface $parentCommand

@return CommandInterface
Store related instance .