private function correctNavigationIfEmpty($parentSection, $pathBuilder, $menu) { $prev = $next = ''; if (!is_array($parentSection)) { return array('next' => $menu['next'], 'prev' => $menu['prev']); } $sectionIterator = new contentTreeSectionIterator(new ArrayIterator($parentSection)); foreach ($sectionIterator as $key => $topic) { if ($sectionIterator->key() == $pathBuilder->getParentName()) { $prev = $sectionIterator->getPrevTopicData(); $next = $sectionIterator->getNextTopicData(); if (is_array($next)) { $next['href'] = '../' . $next['href']; } if (is_array($prev)) { $prev['href'] = '../' . $prev['href']; } break; } } $next = $menu['next'] ? $menu['next'] : $next; $prev = $menu['prev'] ? $menu['prev'] : $prev; return array('next' => $next, 'prev' => $prev); }