/** * Retrieves an array of siblings * @param \Navinator\Collection $collection Collection context get siblings from * @param bool $includeSelf If true this node will be included in the list */ public function getSiblings(\Navinator\Collection $collection, $includeSelf = false) { $siblings = array(); $depth = $this->getDepth(); if ($depth == 1) { $siblings = $collection->getRootNodes(); } else { $parentPath = $this->getParentPath(); foreach ($collection->getNode() as $node) { if (StringHelper::strStartsWith($parentPath . '/', $node->getPath()) && $node->getDepth() == $depth) { $siblings[$node->getPath()] = $node; } } } if (!$includeSelf) { unset($siblings[$this->getPath()]); } return $siblings; }