protected function renderSpanElement(ItemInterface $item, array $options) { return sprintf('<span%s>%s</span>', $this->renderHtmlAttributes($item->getLabelAttributes()), $item->getName()); }
/** * 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 \Knp\Menu\ItemInterface $item The item to render the link or label for * @param array $options The options to render the item * @return string */ public function renderLink(ItemInterface $item, array $options = array()) { $options = array_merge($this->getDefaultOptions(), $options); if ($item->getUri() && (!$item->isCurrent() || $options['currentAsLink'])) { $text = sprintf('<a href="%s"%s>%s</a>', $this->escape($item->getUri()), $this->renderHtmlAttributes($item->getLinkAttributes()), $this->escape($item->getLabel())); } else { $text = sprintf('<span%s>%s</span>', $this->renderHtmlAttributes($item->getLabelAttributes()), $this->escape($item->getLabel())); } return $this->format($text, 'link', $item->getLevel()); }
protected function renderSpanElement(ItemInterface $item, array $options) { return sprintf('<a href="#"%s><i class="fa fa-th-%s"></i><span>%s</span><i class="arrow fa fa-chevron-right"></i></a>', $this->renderHtmlAttributes($item->getLabelAttributes()), $options['icon'], $this->renderLabel($item, $options)); }
/** * @param \Knp\Menu\ItemInterface $item * @param array $options * @return Html */ protected function getSpanElement(ItemInterface $item, array $options) { return Html::el('span', $item->getLabelAttributes())->setHtml($this->getText($item, $options)); }
/** * @param ItemInterface $item * @param integer|null $depth the depth until which children should be exported (null means unlimited) * * @return array */ public function toArray(ItemInterface $item, $depth = null) { $array = array('name' => $item->getName(), 'label' => $item->getLabel(), 'uri' => $item->getUri(), 'attributes' => $item->getAttributes(), 'labelAttributes' => $item->getLabelAttributes(), 'linkAttributes' => $item->getLinkAttributes(), 'childrenAttributes' => $item->getChildrenAttributes(), 'extras' => $item->getExtras(), 'display' => $item->isDisplayed(), 'displayChildren' => $item->getDisplayChildren(), 'current' => $item->isCurrent()); // export the children as well, unless explicitly disabled if (0 !== $depth) { $childDepth = null === $depth ? null : $depth - 1; $array['children'] = array(); foreach ($item->getChildren() as $key => $child) { $array['children'][$key] = $this->toArray($child, $childDepth); } } return $array; }