src/Node/Node.php
public function findParents(array $filters = [], array $options = [])
    {
        $options = array_replace(
            [
                'returnFirstResult' => false,
                'indexById'         => false
            ],
            $options
        );
        $parents = $this->getAllParents($options);

        if ($parents && $filters) {
            $result = [];

            /** @var NodeInterface $parent */
            foreach ($parents as $i => $parent) {
                foreach ($filters as $f => $v) {
                    $method = 'get' . ucfirst($f);

                    if (!method_exists($parent, $method) || $parent->$method() !== $v) {
                        continue 2;
                    }
                }

                if ($options['indexById']) {
                    $result[$i] = $parent;
                } else {
                    $result[] = $parent;
                }
            }
        } else {
            $result = $parents;
        }

        return $options['returnFirstResult'] && $result ?
            array_values($result)[0] :
            $result;
    }
public function findParents(array $filters = [], array $options = [])
    {
        $options = array_replace(
            [
                'returnFirstResult' => false,
                'indexById'         => false
            ],
            $options
        );
        $parents = $this->getAllParents($options);

        if ($parents && $filters) {
            $result = [];

            /** @var NodeInterface $parent */
            foreach ($parents as $i => $parent) {
                foreach ($filters as $f => $v) {
                    $method = 'get' . ucfirst($f);

                    if (!method_exists($parent, $method) || $parent->$method() !== $v) {
                        continue 2;
                    }
                }

                if ($options['indexById']) {
                    $result[$i] = $parent;
                } else {
                    $result[] = $parent;
                }
            }
        } else {
            $result = $parents;
        }

        return $options['returnFirstResult'] && $result ?
            array_values($result)[0] :
            $result;
    }
public function findParents ( array $ filters = [ ] , array $ options = [ ] ) { $ options = array_replace ( [ 'returnFirstResult' => false , 'indexById' => false ] , $ options ) ; $ parents = $ this -> getAllParents ( $ options ) ; if ( $ parents && $ filters ) { $ result = [ ] ; /** @var NodeInterface $parent */ foreach ( $ parents as $ i => $ parent ) { foreach ( $ filters as $ f => $ v ) { $ method = 'get' . ucfirst ( $ f ) ; if ( ! method_exists ( $ parent , $ method ) || $ parent -> $ method ( ) !== $ v ) { continue 2 ; } } if ( $ options [ 'indexById' ] ) { $ result [ $ i ] = $ parent ; } else { $ result [ ] = $ parent ; } } } else { $ result = $ parents ; } return $ options [ 'returnFirstResult' ] && $ result ? array_values ( $ result ) [ 0 ] : $ result ; }
Finds parent nodes all the way up until we reach the root node.

@param array $filters - Filters.
@param array $options - Options.

@return array|NodeInterface
Finds parent nodes all the way up until we reach the root node .