public function getSectionHtml(array $sections, ContentInterface $content) { $html = ''; ksort($sections); if (count($sections) > 0) { $html .= '<br /><ul>'; } foreach ($sections as $section) { //todo: this is just an array and could contain anything. Too much of a convention. //todo: consider using an array of some new object? $html .= '<li><a href="' . $content->getAnchorPath($section['id']) . '">' . $section['title'] . '</a></li>' . "\r\n"; } if (count($sections) > 0) { $html .= '</ul>' . "\r\n"; } return $html; }
/** * Method used for sorting with usort by position of Content * * @param ContentInterface $c1 * @param ContentInterface $c2 * @return int */ private function sortByPosition(ContentInterface $c1, ContentInterface $c2) { if ($c1->getPosition() == $c2->getPosition()) { return 0; } return $c1->getPosition() < $c2->getPosition() ? -1 : 1; }