Builder/ItemProcess.php
private function recursiveProcess(ItemInterface $menu, $options)
    {
        // Get Child Menus
        $childs = $menu->getChild();

        // Parent Menu Route
        if (isset($menu->getChildAttr()['data-parent'])) {
            $menu->setChildAttr(['data-parent' => $this->router->generate($menu->getChildAttr()['data-parent'])]);
        }

        // Sort Current Child
        foreach ($childs as $child) {
            // Generate Route Link
            if ($child->getRoute()) {
                $child->setLink($this->router->generate($child->getRoute()['name'], $child->getRoute()['params']));

                // Link Active Class
                if ($this->currentUri === $child->getLink()) {
                    $child->setListAttr(array_merge_recursive($child->getListAttr(), ['class' => $options['currentClass']]));
                }
            }

            // Item Security
            if ($child->getRoles()) {
                if (!$this->security->isGranted($child->getRoles())) {
                    unset($childs[$child->getId()]);
                }
            }

            // Set Child Process
            if ($child->getChild()) {
                // Set Menu Depth
                if (null !== $options['depth'] && ($child->getLevel() >= $options['depth'])) {
                    $child->setChild([]);
                    break;
                }

                // Set Child List Class
                $child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_' . $child->getLevel()]));

                $this->recursiveProcess($child, $options);
            }
        }

        // Sort Item
        usort($childs, function ($a, $b) {
            return $a->getOrder() > $b->getOrder();
        });

        // Set Childs
        $menu->setChild($childs);
    }
private function recursiveProcess(ItemInterface $menu, $options)
    {
        // Get Child Menus
        $childs = $menu->getChild();

        // Parent Menu Route
        if (isset($menu->getChildAttr()['data-parent'])) {
            $menu->setChildAttr(['data-parent' => $this->router->generate($menu->getChildAttr()['data-parent'])]);
        }

        // Sort Current Child
        foreach ($childs as $child) {
            // Generate Route Link
            if ($child->getRoute()) {
                $child->setLink($this->router->generate($child->getRoute()['name'], $child->getRoute()['params']));

                // Link Active Class
                if ($this->currentUri === $child->getLink()) {
                    $child->setListAttr(array_merge_recursive($child->getListAttr(), ['class' => $options['currentClass']]));
                }
            }

            // Item Security
            if ($child->getRoles()) {
                if (!$this->security->isGranted($child->getRoles())) {
                    unset($childs[$child->getId()]);
                }
            }

            // Set Child Process
            if ($child->getChild()) {
                // Set Menu Depth
                if (null !== $options['depth'] && ($child->getLevel() >= $options['depth'])) {
                    $child->setChild([]);
                    break;
                }

                // Set Child List Class
                $child->setChildAttr(array_merge_recursive($child->getChildAttr(), ['class' => 'menu_level_' . $child->getLevel()]));

                $this->recursiveProcess($child, $options);
            }
        }

        // Sort Item
        usort($childs, function ($a, $b) {
            return $a->getOrder() > $b->getOrder();
        });

        // Set Childs
        $menu->setChild($childs);
    }
private function recursiveProcess ( ItemInterface $ menu , $ options ) { // Get Child Menus $ childs = $ menu -> getChild ( ) ; // Parent Menu Route if ( isset ( $ menu -> getChildAttr ( ) [ 'data-parent' ] ) ) { $ menu -> setChildAttr ( [ 'data-parent' => $ this -> router -> generate ( $ menu -> getChildAttr ( ) [ 'data-parent' ] ) ] ) ; } // Sort Current Child foreach ( $ childs as $ child ) { // Generate Route Link if ( $ child -> getRoute ( ) ) { $ child -> setLink ( $ this -> router -> generate ( $ child -> getRoute ( ) [ 'name' ] , $ child -> getRoute ( ) [ 'params' ] ) ) ; // Link Active Class if ( $ this -> currentUri === $ child -> getLink ( ) ) { $ child -> setListAttr ( array_merge_recursive ( $ child -> getListAttr ( ) , [ 'class' => $ options [ 'currentClass' ] ] ) ) ; } } // Item Security if ( $ child -> getRoles ( ) ) { if ( ! $ this -> security -> isGranted ( $ child -> getRoles ( ) ) ) { unset ( $ childs [ $ child -> getId ( ) ] ) ; } } // Set Child Process if ( $ child -> getChild ( ) ) { // Set Menu Depth if ( null !== $ options [ 'depth' ] && ( $ child -> getLevel ( ) >= $ options [ 'depth' ] ) ) { $ child -> setChild ( [ ] ) ; break ; } // Set Child List Class $ child -> setChildAttr ( array_merge_recursive ( $ child -> getChildAttr ( ) , [ 'class' => 'menu_level_' . $ child -> getLevel ( ) ] ) ) ; $ this -> recursiveProcess ( $ child , $ options ) ; } } // Sort Item usort ( $ childs , function ( $ a , $ b ) { return $ a -> getOrder ( ) > $ b -> getOrder ( ) ; } ) ; // Set Childs $ menu -> setChild ( $ childs ) ; }
Process Menu Item.

@param ItemInterface $menu
@param $options
Process Menu Item .