Example #1
0
 /**
  * Render an item's sub-items.
  *
  * @param  Menu\Items\Item  $list
  * @param  int              $depth
  * @return string
  */
 public function renderList(Item $list, $depth = 1)
 {
     $output = '';
     $items = $list->items();
     if (!empty($items)) {
         $output = $this->format('<ul' . $this->attributes($list->ul) . '>', $depth);
         $itemCount = count($items);
         foreach ($items as $item) {
             // If this is the only item of its level, give it the single item class.
             if ($itemCount == 1) {
                 $this->addClass($item->label, $this->singleClass);
             }
             $output .= $this->renderItem($item, $depth + 1);
         }
         $output .= $this->format('</ul>', $depth);
     }
     return $output;
 }