Lavary\Menu\Builder::render PHP Метод

render() публичный Метод

Generate the menu items as list items using a recursive function
public render ( string $type = 'ul', integer $parent = null, $childrenAttributes = [] ) : string
$type string
$parent integer
Результат string
    public function render($type = 'ul', $parent = null, $childrenAttributes = array())
    {
        $items = '';
        $item_tag = in_array($type, array('ul', 'ol')) ? 'li' : $type;
        foreach ($this->whereParent($parent) as $item) {
            $items .= '<' . $item_tag . self::attributes($item->attr()) . '>';
            if ($item->link) {
                $items .= '<a' . self::attributes($item->link->attr()) . ' href="' . $item->url() . '">' . $item->title . '</a>';
            } else {
                $items .= $item->title;
            }
            if ($item->hasChildren()) {
                $items .= '<' . $type . self::attributes($childrenAttributes) . '>';
                $items .= $this->render($type, $item->id);
                $items .= "</{$type}>";
            }
            $items .= "</{$item_tag}>";
            if ($item->divider) {
                $items .= '<' . $item_tag . self::attributes($item->divider) . '></' . $item_tag . '>';
            }
        }
        return $items;
    }