components/helpers/NavHelper.php
public static function applyActive(&$Nav)
    {
        if ($Nav) {
            foreach ($Nav as &$one) {
                if (isset($one['items'])) {
                    self::applyActive($one['items']);
                }

                if (!isset($one['active'])) {
                    if (is_array($one['url'])) {

                        $url = $one['url'][0];
                        $route = Yii::$app->requestedRoute;
                        $params = Yii::$app->request->getQueryParams();

                        if ($url === '/' && $route === Yii::$app->controller->module->id . '/dashboard/index') {
                            $one['active'] = true;
                        } else {
                            $url = $one['url'];
                            $urlExploded = explode('/', $url[0]);

                            $one['submenuTemplate'] = '';
                            foreach (self::$active as $activeAction) {
                                $urlExploded[count($urlExploded) - 1] = $activeAction;
                                $url[0] = implode('/', $urlExploded);

                                $one['items'][] =
                                    [
                                        'label' => $one['label'] . ' - ' . $activeAction,
                                        'url' => $url,
                                        'options' => [
                                            'class' => 'hidden'
                                        ]
                                    ];

                                if ('/' . Yii::$app->request->getQueryParam('parentRoute') === trim($url[0])) {
                                    $one['items'][] =
                                        [
                                            'label' => $one['label'] . ' - Sub List',
                                            'url' => array_merge(['/' . $route], $params),
                                            'options' => [
                                                'class' => 'hidden'
                                            ]
                                        ];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
public static function applyActive(&$Nav)
    {
        if ($Nav) {
            foreach ($Nav as &$one) {
                if (isset($one['items'])) {
                    self::applyActive($one['items']);
                }

                if (!isset($one['active'])) {
                    if (is_array($one['url'])) {

                        $url = $one['url'][0];
                        $route = Yii::$app->requestedRoute;
                        $params = Yii::$app->request->getQueryParams();

                        if ($url === '/' && $route === Yii::$app->controller->module->id . '/dashboard/index') {
                            $one['active'] = true;
                        } else {
                            $url = $one['url'];
                            $urlExploded = explode('/', $url[0]);

                            $one['submenuTemplate'] = '';
                            foreach (self::$active as $activeAction) {
                                $urlExploded[count($urlExploded) - 1] = $activeAction;
                                $url[0] = implode('/', $urlExploded);

                                $one['items'][] =
                                    [
                                        'label' => $one['label'] . ' - ' . $activeAction,
                                        'url' => $url,
                                        'options' => [
                                            'class' => 'hidden'
                                        ]
                                    ];

                                if ('/' . Yii::$app->request->getQueryParam('parentRoute') === trim($url[0])) {
                                    $one['items'][] =
                                        [
                                            'label' => $one['label'] . ' - Sub List',
                                            'url' => array_merge(['/' . $route], $params),
                                            'options' => [
                                                'class' => 'hidden'
                                            ]
                                        ];
                                }
                            }
                        }
                    }
                }
            }
        }
    }
public static function applyActive ( & $ Nav ) { if ( $ Nav ) { foreach ( $ Nav as & $ one ) { if ( isset ( $ one [ 'items' ] ) ) { self :: applyActive ( $ one [ 'items' ] ) ; } if ( ! isset ( $ one [ 'active' ] ) ) { if ( is_array ( $ one [ 'url' ] ) ) { $ url = $ one [ 'url' ] [ 0 ] ; $ route = Yii :: $ app -> requestedRoute ; $ params = Yii :: $ app -> request -> getQueryParams ( ) ; if ( $ url === '/' && $ route === Yii :: $ app -> controller -> module -> id . '/dashboard/index' ) { $ one [ 'active' ] = true ; } else { $ url = $ one [ 'url' ] ; $ urlExploded = explode ( '/' , $ url [ 0 ] ) ; $ one [ 'submenuTemplate' ] = '' ; foreach ( self :: $ active as $ activeAction ) { $ urlExploded [ count ( $ urlExploded ) - 1 ] = $ activeAction ; $ url [ 0 ] = implode ( '/' , $ urlExploded ) ; $ one [ 'items' ] [ ] = [ 'label' => $ one [ 'label' ] . ' - ' . $ activeAction , 'url' => $ url , 'options' => [ 'class' => 'hidden' ] ] ; if ( '/' . Yii :: $ app -> request -> getQueryParam ( 'parentRoute' ) === trim ( $ url [ 0 ] ) ) { $ one [ 'items' ] [ ] = [ 'label' => $ one [ 'label' ] . ' - Sub List' , 'url' => array_merge ( [ '/' . $ route ] , $ params ) , 'options' => [ 'class' => 'hidden' ] ] ; } } } } } } } }
Apply active attriute depends on route
@param $Nav
Apply active attriute depends on route