Menu\Items\Item::render PHP Method

render() public method

Render the item
public render ( $depth ) : string
return string
    public function render($depth = 0)
    {
        // Add the active classes
        $value = is_null($this->beforeContent) ? '' : $this->beforeContent;
        $value .= $this->value->render();
        $value .= is_null($this->afterContent) ? '' : $this->afterContent;
        $this->addActiveClasses();
        // Render children if any
        if ($this->hasChildren()) {
            $value .= $this->children->render($depth);
        }
        // Facultatively render an element around the item
        $element = $this->getElement();
        if ($element) {
            $value = Element::create($element, $value, $this->attributes)->render();
        }
        return html_entity_decode($value, ENT_QUOTES, 'UTF-8');
    }

Usage Example

Example #1
0
 public function testCanCreateElementlessItems()
 {
     $item = new Item(static::$itemList, static::$link);
     $item->setElement(null);
     $this->assertHTML($this->matchLink(), $item->render());
 }