示例#1
0
 public function isCurrent(ItemInterface $item)
 {
     $current = $item->isCurrent();
     if (null !== $current) {
         return $current;
     }
     if ($this->cache->contains($item)) {
         return $this->cache[$item];
     }
     foreach ($this->voters as $voter) {
         $current = $voter->matchItem($item);
         if (null !== $current) {
             break;
         }
     }
     $current = (bool) $current;
     $this->cache[$item] = $current;
     return $current;
 }
示例#2
0
 /**
  * Renders the link in a a tag with link attributes or
  * the label in a span tag with label attributes
  *
  * Tests if item has a an uri and if not tests if it's
  * the current item and if the text has to be rendered
  * as a link or not.
  *
  * @param ItemInterface $item    The item to render the link or label for
  * @param array         $options The options to render the item
  *
  * @return string
  */
 protected function renderLink(ItemInterface $item, array $options = array())
 {
     if ($item->getUri() && (!$item->isCurrent() || $options['currentAsLink'])) {
         $text = $this->renderLinkElement($item, $options);
     } else {
         $text = $this->renderSpanElement($item, $options);
     }
     return $this->format($text, 'link', $item->getLevel(), $options);
 }