App\Traits\MenuHandlerTrait::renderBreadcrumbTrail PHP 메소드

renderBreadcrumbTrail() 공개 메소드

public renderBreadcrumbTrail ( null $leaf = null, string $topNode = 'root', boolean $includeTopNode = false ) : Illuminate\View\View
$leaf null
$topNode string
$includeTopNode boolean
리턴 Illuminate\View\View
    public function renderBreadcrumbTrail($leaf = null, $topNode = 'root', $includeTopNode = false)
    {
        $trailContent = "";
        try {
            $bContinue = true;
            $leaf = $this->GetLeafMenuItem($leaf);
            $topNode = $this->getMenuItem($topNode);
            $variables = $this->getVariables($leaf);
            $trailContent = $this->replaceVars($this->TRAIL_FOOTER, $variables);
            $trailNode = $leaf;
            while ($bContinue) {
                $trailContent = $this->renderBreadcrumbTrailItem($trailNode, $variables) . $trailContent;
                // If we already reached the top node
                if ($topNode->id == $trailNode->id) {
                    $bContinue = false;
                } elseif ($topNode->id == $trailNode->parent->id && $includeTopNode) {
                    $trailNode = $trailNode->parent;
                } elseif ($topNode->id == $trailNode->parent->id && !$includeTopNode) {
                    $bContinue = false;
                } else {
                    $trailNode = $trailNode->parent;
                }
            }
            $trailContent = $this->replaceVars($this->TRAIL_HEADER, $variables) . $trailContent;
        } catch (\Exception $ex) {
            $trailContent = "<!-- Failed to render breadcrumb trail -->";
            Log::error('Failed to render breadcrumb trail.', ['Exception' => $ex]);
        }
        return view($this->TRAIL_PARTIAL_VIEW, compact('trailContent'));
    }