App\Traits\MenuHandlerTrait::renderMenu PHP Метод

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

Builds a representation of the menu for the defined framework and return it starting at the $topNode.
public renderMenu ( string $topNode = 'root', boolean $includeTopNode = false ) : Illuminate\View\View
$topNode string can be an instance of a Menu object, it's id or name. It is set to 'root' by default.
$includeTopNode boolean indicates whether to include the root node itself or not. It's default value is 'false'.
Результат Illuminate\View\View
    public function renderMenu($topNode = 'root', $includeTopNode = false)
    {
        $menuContent = "";
        try {
            $topNode = $this->getMenuItem($topNode);
            $menuBranch = $this->getMenuBranch();
            $variables = $this->getVariables($topNode);
            $menuContent = $this->replaceVars($this->MENU_HEADER, $variables);
            if ($includeTopNode) {
                $menuContent .= $this->renderMenuItem($topNode, $variables, $menuBranch);
            } else {
                $children = $topNode->children;
                foreach ($children as $child) {
                    $menuContent .= $this->renderMenuItem($child, $variables, $menuBranch);
                }
            }
            $menuContent .= $this->replaceVars($this->MENU_FOOTER, $variables);
        } catch (\Exception $ex) {
            $menuContent = "<!-- Failed to render menu -->";
        }
        return view($this->MENU_PARTIAL_VIEW, compact('menuContent'));
    }