protected function populateRelationAsyncSingle($name, &$primaryModels) {
        return $this->one()->otherwise(function() { return null; })->then(
            function($model) use ($name, &$primaryModels) {
                $primaryModel = reset($primaryModels);
                if ($primaryModel instanceof ActiveRecordInterface) {
                    $primaryModel->populateRelation($name, $model);
                } else {
                    $primaryModels[key($primaryModels)][$name] = $model;
                }
                if ($this->inverseOf !== null) {
                    $this->populateInverseRelation($primaryModels, [$model], $name, $this->inverseOf);
                }

                return [$model];
            }
        );
    }
protected function populateRelationAsyncSingle($name, &$primaryModels) {
        return $this->one()->otherwise(function() { return null; })->then(
            function($model) use ($name, &$primaryModels) {
                $primaryModel = reset($primaryModels);
                if ($primaryModel instanceof ActiveRecordInterface) {
                    $primaryModel->populateRelation($name, $model);
                } else {
                    $primaryModels[key($primaryModels)][$name] = $model;
                }
                if ($this->inverseOf !== null) {
                    $this->populateInverseRelation($primaryModels, [$model], $name, $this->inverseOf);
                }

                return [$model];
            }
        );
    }
protected function populateRelationAsyncSingle ( $ name , & $ primaryModels ) { return $ this -> one ( ) -> otherwise ( function ( ) { return null ; } ) -> then ( function ( $ model ) use ( $ name , & $ primaryModels ) { $ primaryModel = reset ( $ primaryModels ) ; if ( $ primaryModel instanceof ActiveRecordInterface ) { $ primaryModel -> populateRelation ( $ name , $ model ) ; } else { $ primaryModels [ key ( $ primaryModels ) ] [ $ name ] = $ model ; } if ( $ this -> inverseOf !== null ) { $ this -> populateInverseRelation ( $ primaryModels , [ $ model ] , $ name , $ this -> inverseOf ) ; } return [ $ model ] ; } ) ; }
Populate relation for single primary model
@param string $name
@param ActiveRecordInterface[] $primaryModels
@return ExtendedPromiseInterface
Populate relation for single primary model