private function buildList(QueryIteratorFilter $iterator, $i = 1)
    {
        // Abort if maxDepth is set & reached
        if ($this->maxDepth !== null && $i >= ($this->maxDepth + 1)) {
            return "";
        }

        // Add the listDepthClassPrefix manually
        $listOptions = $this->listOptions;

        if (!isset($listOptions['class'])) {
            $listOptions['class'] = "";
        }

        $listOptions['class'] .= " " . $this->listDepthClassPrefix . $i;

        // <ul>
        $html = "";

        if ($this->ignoreFirstListTag && $i !== 1 || !$this->ignoreFirstListTag) {
            $html = Html::beginTag($this->_listTag, $listOptions);
        }

        foreach ($iterator as $item) {
            $itemOptions = $this->itemOptions;
            $linkOptions = array_merge($this->linkOptions, ['href' => $item->link]);

            // Set the active classes if item is active
            if ($item->isActive) {
                $itemOptions['class'] .= $this->itemActiveClass !== null ? ' ' . $this->itemActiveClass : '';
                $linkOptions['class'] .= $this->linkActiveClass !== null ? ' ' . $this->linkActiveClass : '';
            }

            // <li>
            $html .= Html::beginTag($this->_itemTag, $this->compileOption($item, $itemOptions));

            // <a></a>
            $html .= Html::tag($this->_linkTag, $item->title, $this->compileOption($item, $linkOptions));

            // Recursive iterate if item has Children
            if ($item->hasChildren) {
                $html .= $this->buildList($item->children, $i + 1);
            }

            // </li>
            $html .= Html::endTag($this->_itemTag);
        }

        if ($this->ignoreFirstListTag && $i !== 1 || !$this->ignoreFirstListTag) {
            // </ul>
            $html .= Html::endTag($this->_listTag);
        }

        return $html;
    }
private function buildList(QueryIteratorFilter $iterator, $i = 1)
    {
        // Abort if maxDepth is set & reached
        if ($this->maxDepth !== null && $i >= ($this->maxDepth + 1)) {
            return "";
        }

        // Add the listDepthClassPrefix manually
        $listOptions = $this->listOptions;

        if (!isset($listOptions['class'])) {
            $listOptions['class'] = "";
        }

        $listOptions['class'] .= " " . $this->listDepthClassPrefix . $i;

        // <ul>
        $html = "";

        if ($this->ignoreFirstListTag && $i !== 1 || !$this->ignoreFirstListTag) {
            $html = Html::beginTag($this->_listTag, $listOptions);
        }

        foreach ($iterator as $item) {
            $itemOptions = $this->itemOptions;
            $linkOptions = array_merge($this->linkOptions, ['href' => $item->link]);

            // Set the active classes if item is active
            if ($item->isActive) {
                $itemOptions['class'] .= $this->itemActiveClass !== null ? ' ' . $this->itemActiveClass : '';
                $linkOptions['class'] .= $this->linkActiveClass !== null ? ' ' . $this->linkActiveClass : '';
            }

            // <li>
            $html .= Html::beginTag($this->_itemTag, $this->compileOption($item, $itemOptions));

            // <a></a>
            $html .= Html::tag($this->_linkTag, $item->title, $this->compileOption($item, $linkOptions));

            // Recursive iterate if item has Children
            if ($item->hasChildren) {
                $html .= $this->buildList($item->children, $i + 1);
            }

            // </li>
            $html .= Html::endTag($this->_itemTag);
        }

        if ($this->ignoreFirstListTag && $i !== 1 || !$this->ignoreFirstListTag) {
            // </ul>
            $html .= Html::endTag($this->_listTag);
        }

        return $html;
    }
private function buildList ( QueryIteratorFilter $ iterator , $ i = 1 ) { // Abort if maxDepth is set & reached if ( $ this -> maxDepth !== null && $ i >= ( $ this -> maxDepth + 1 ) ) { return "" ; } // Add the listDepthClassPrefix manually $ listOptions = $ this -> listOptions ; if ( ! isset ( $ listOptions [ 'class' ] ) ) { $ listOptions [ 'class' ] = "" ; } $ listOptions [ 'class' ] .= " " . $ this -> listDepthClassPrefix . $ i ; // <ul> $ html = "" ; if ( $ this -> ignoreFirstListTag && $ i !== 1 || ! $ this -> ignoreFirstListTag ) { $ html = Html :: beginTag ( $ this -> _listTag , $ listOptions ) ; } foreach ( $ iterator as $ item ) { $ itemOptions = $ this -> itemOptions ; $ linkOptions = array_merge ( $ this -> linkOptions , [ 'href' => $ item -> link ] ) ; // Set the active classes if item is active if ( $ item -> isActive ) { $ itemOptions [ 'class' ] .= $ this -> itemActiveClass !== null ? ' ' . $ this -> itemActiveClass : '' ; $ linkOptions [ 'class' ] .= $ this -> linkActiveClass !== null ? ' ' . $ this -> linkActiveClass : '' ; } // <li> $ html .= Html :: beginTag ( $ this -> _itemTag , $ this -> compileOption ( $ item , $ itemOptions ) ) ; // <a></a> $ html .= Html :: tag ( $ this -> _linkTag , $ item -> title , $ this -> compileOption ( $ item , $ linkOptions ) ) ; // Recursive iterate if item has Children if ( $ item -> hasChildren ) { $ html .= $ this -> buildList ( $ item -> children , $ i + 1 ) ; } // </li> $ html .= Html :: endTag ( $ this -> _itemTag ) ; } if ( $ this -> ignoreFirstListTag && $ i !== 1 || ! $ this -> ignoreFirstListTag ) { // </ul> $ html .= Html :: endTag ( $ this -> _listTag ) ; } return $ html ; }
Builds the list for the given Iterator and recursively calls itself to also generate the menu for all children

@param QueryIteratorFilter $iterator The iterator used to build the list
@param int $i The counter that is used to set the list depth
@return string Part of the menu
Builds the list for the given Iterator and recursively calls itself to also generate the menu for all children