示例#1
0
 /**
  * Renders all of the children of this landmark.
  *
  * This calls ->renderItem() on each landmark item, which instructs each
  * landmark item to render themselves as an <li> tag (with nested ul if it
  * has children).
  * This method updates the depth for the children.
  *
  * @param ItemInterface $item
  * @param array         $options The options to render the item.
  *
  * @return string
  */
 protected function renderChildren(ItemInterface $item, array $options)
 {
     // render children with a depth - 1
     if (null !== $options['depth']) {
         $options['depth'] = $options['depth'] - 1;
     }
     $html = '';
     foreach ($item->getChildren() as $child) {
         $html .= $this->renderItem($child, $options);
     }
     return $html;
 }
示例#2
0
 public function isAncestor(ItemInterface $item, $depth = null)
 {
     if (0 === $depth) {
         return false;
     }
     $childDepth = null === $depth ? null : $depth - 1;
     foreach ($item->getChildren() as $child) {
         if ($this->isCurrent($child) || $this->isAncestor($child, $childDepth)) {
             return true;
         }
     }
     return false;
 }