components/helpers/NavHelper.php
public static function applyVisible(&$Nav)
    {
        if ($Nav) {
            foreach ($Nav as &$one) {
                if (!isset($one['visible'])) {
                    if (isset($one['permission'])) {
                        $authItemModel = Yii::createObject(AuthItem::class);
                        $one['visible'] = Yii::$app->user->can($authItemModel::SUPER_ADMIN) || Yii::$app->user->can($one['permission']);
                    } else {
                        if (is_array($one['url'])) {
                            $url = explode('/', trim($one['url'][0], '/'));
                            if (isset($url['0']) && isset($url['1'])) {
                                $one['visible'] = Yii::$app->user->can('Super admin') || Yii::$app->user->can($url[0] . '/' . $url[1]);
                            }
                        }
                    }
                }

                if (isset($one['items'])) {
                    self::applyVisible($one['items']);
                }
            }
        }

    }
public static function applyVisible(&$Nav)
    {
        if ($Nav) {
            foreach ($Nav as &$one) {
                if (!isset($one['visible'])) {
                    if (isset($one['permission'])) {
                        $authItemModel = Yii::createObject(AuthItem::class);
                        $one['visible'] = Yii::$app->user->can($authItemModel::SUPER_ADMIN) || Yii::$app->user->can($one['permission']);
                    } else {
                        if (is_array($one['url'])) {
                            $url = explode('/', trim($one['url'][0], '/'));
                            if (isset($url['0']) && isset($url['1'])) {
                                $one['visible'] = Yii::$app->user->can('Super admin') || Yii::$app->user->can($url[0] . '/' . $url[1]);
                            }
                        }
                    }
                }

                if (isset($one['items'])) {
                    self::applyVisible($one['items']);
                }
            }
        }

    }
Apply visible attribute depends on permission or url
@param $Nav