public function getJointParent($model, $includeSelf = false)
    {
        if ( is_numeric($model) ) {
            $model = call_user_func("$this->ownerClassName::findOne", $model);
        }
        if ( $this->owner->{$this->parentIdField} == $model->{$this->parentIdField} ) {
            return $this->getParent();
        }
        $ownerParents = $this->owner->getParents($includeSelf)->all();
        $modelParents = $model->getParents($includeSelf)->all();
        $jointParent = false;
        foreach ( $ownerParents as $idx => $parent ) {
            if ( isset($modelParents[$idx]) && $parent->{$this->primaryKey} == $modelParents[$idx]->{$this->primaryKey} ) {
                $jointParent = $parent;
            } else {
                break;
            }
        }
        return $jointParent;
    }
public function getJointParent($model, $includeSelf = false)
    {
        if ( is_numeric($model) ) {
            $model = call_user_func("$this->ownerClassName::findOne", $model);
        }
        if ( $this->owner->{$this->parentIdField} == $model->{$this->parentIdField} ) {
            return $this->getParent();
        }
        $ownerParents = $this->owner->getParents($includeSelf)->all();
        $modelParents = $model->getParents($includeSelf)->all();
        $jointParent = false;
        foreach ( $ownerParents as $idx => $parent ) {
            if ( isset($modelParents[$idx]) && $parent->{$this->primaryKey} == $modelParents[$idx]->{$this->primaryKey} ) {
                $jointParent = $parent;
            } else {
                break;
            }
        }
        return $jointParent;
    }
public function getJointParent ( $ model , $ includeSelf = false ) { if ( is_numeric ( $ model ) ) { $ model = call_user_func ( "$this->ownerClassName::findOne" , $ model ) ; } if ( $ this -> owner -> { $ this -> parentIdField } == $ model -> { $ this -> parentIdField } ) { return $ this -> getParent ( ) ; } $ ownerParents = $ this -> owner -> getParents ( $ includeSelf ) -> all ( ) ; $ modelParents = $ model -> getParents ( $ includeSelf ) -> all ( ) ; $ jointParent = false ; foreach ( $ ownerParents as $ idx => $ parent ) { if ( isset ( $ modelParents [ $ idx ] ) && $ parent -> { $ this -> primaryKey } == $ modelParents [ $ idx ] -> { $ this -> primaryKey } ) { $ jointParent = $ parent ; } else { break ; } } return $ jointParent ; }
Return joint parent of two models or false if it's not exists.
@param \yii\db\ActiveRecord $model
@param boolean $includeSelf
@return \yii\db\ActiveRecord|false
Return joint parent of two models or false if it s not exists .