public function getCommonAncestor($model)
    {
        if (empty($this->parentAttribute) || !is_string($this->parentAttribute) ||
            empty($model) || !$model->hasParent()) {
            return null;
        }
        $ancestors = $this->getAncestorChain();
        if (in_array($model->parent->getRefId(), $ancestors)) {
            return $model->parent;
        }
        return $this->getCommonAncestor($model->parent);
    }
public function getCommonAncestor($model)
    {
        if (empty($this->parentAttribute) || !is_string($this->parentAttribute) ||
            empty($model) || !$model->hasParent()) {
            return null;
        }
        $ancestors = $this->getAncestorChain();
        if (in_array($model->parent->getRefId(), $ancestors)) {
            return $model->parent;
        }
        return $this->getCommonAncestor($model->parent);
    }
public function getCommonAncestor ( $ model ) { if ( empty ( $ this -> parentAttribute ) || ! is_string ( $ this -> parentAttribute ) || empty ( $ model ) || ! $ model -> hasParent ( ) ) { return null ; } $ ancestors = $ this -> getAncestorChain ( ) ; if ( in_array ( $ model -> parent -> getRefId ( ) , $ ancestors ) ) { return $ model -> parent ; } return $ this -> getCommonAncestor ( $ model -> parent ) ; }
Get common ancestor. If there isn't common ancestor, null will be given.
@param static $model
@return static
Get common ancestor . If there isn t common ancestor null will be given .