public function render($depth = 0)
{
if (!is_int($depth)) {
throw new Exception("The render method doesn't take any arguments anymore, you can now configure your menu via the config file.");
}
// Check for maximal depth
$maxDepth = $this->getOption('max_depth');
if ($maxDepth !== -1 and $depth > $maxDepth) {
return false;
}
// Render contained items
$contents = null;
if (count($this->children) == 0) {
return "";
}
foreach ($this->children as $item) {
$contents .= $item->render($depth + 1);
}
$element = $this->getElement();
if ($element) {
$contents = Element::create($element, $contents, $this->attributes)->render();
}
return $contents;
}
public function testMenuCanSetGlobalOptions() { Menu::setOption('item.element', 'dl'); $list = new ItemList(); $list->add('#', 'foo'); $this->assertHTML($this->matchListWithItem('ul', 'dl'), $list->render()); $this->assertHTML($this->matchLink(), $list->render()); }