src/Node/Node.php
public function getAllParents(array $options = []): array
    {
        $options = array_replace(
            [
                'indexById'     => false,
                'skipIds'       => []
            ],
            $options
        );
        $parents = [];
        $ids = [$this->getId()];

        /** @var NodeInterface $parent */
        foreach ($this->getParents() as $id => $parent) {
            if (in_array($id, $options['skipIds'])) {
                continue;
            }

            $ids[] = $id;

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

            $parents = array_merge(
                $parents,
                $parent->getAllParents(array_merge($options, ['skipIds' => $ids]))
            );
        }

        return $parents;
    }
public function getAllParents(array $options = []): array
    {
        $options = array_replace(
            [
                'indexById'     => false,
                'skipIds'       => []
            ],
            $options
        );
        $parents = [];
        $ids = [$this->getId()];

        /** @var NodeInterface $parent */
        foreach ($this->getParents() as $id => $parent) {
            if (in_array($id, $options['skipIds'])) {
                continue;
            }

            $ids[] = $id;

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

            $parents = array_merge(
                $parents,
                $parent->getAllParents(array_merge($options, ['skipIds' => $ids]))
            );
        }

        return $parents;
    }
public function getAllParents ( array $ options = [ ] ) : array { $ options = array_replace ( [ 'indexById' => false , 'skipIds' => [ ] ] , $ options ) ; $ parents = [ ] ; $ ids = [ $ this -> getId ( ) ] ; /** @var NodeInterface $parent */ foreach ( $ this -> getParents ( ) as $ id => $ parent ) { if ( in_array ( $ id , $ options [ 'skipIds' ] ) ) { continue ; } $ ids [ ] = $ id ; if ( $ options [ 'indexById' ] ) { $ parents [ $ id ] = $ parent ; } else { $ parents [ ] = $ parent ; } $ parents = array_merge ( $ parents , $ parent -> getAllParents ( array_merge ( $ options , [ 'skipIds' => $ ids ] ) ) ) ; } return $ parents ; }
Returns all parents from this node.

@param array $options - Options.

@return array
Returns all parents from this node .