public function next() { $level = $this->node->getLevel() + 1; $pathCount = count($this->queryPathList) - 1; while (true) { if (!$this->iterator->valid()) { break; } /** @var $node INode */ $node = $this->iterator->current(); if ($node->getLevel() - $level === $pathCount) { $match = false; $pathIndex = $pathCount; while ($node && $node !== $this->node) { if ($this->queryPathList[$pathIndex--]->match($node) === false) { $match = false; break; } $match = true; $node = $node->getParent(); } if ($match === true) { break; } } $this->iterator->next(); } }
public function getPath(INode $node = null) { $current = $this; $path = []; if ($node && $node->getLevel() >= $this->getLevel()) { throw new NodeException(sprintf('Node [%s] is below current node [%s].', $node->getPath(), $this->getPath())); } while ($current || $node !== null && $current === $node) { $path[] = $current->getName(); $current = $current->getParent(); } return '/' . implode('/', array_reverse(array_filter($path))); }