private static function matchRoute(&$currentMenuLinkIDs, $menuLink, $currentRoute, $menuLinkRoute)
    {
        $menuLinksParams = self::decodeParams($menuLink->params);

        //add language parameter on non-default languages
        if (App::getLocale() != Language::getDefault('slug')) {
            $menuLinksParams['lang'] = App::getLocale();
        }

        //validate params
        $paramsMatch = true;

        if ($menuLinkRoute->parameterNames()) {
            $paramsMatch = false;
            foreach ($menuLinkRoute->parameterNames() as $parameter) {
                if (// Current route parameter is present in MenuLink route
                    isset($menuLinksParams[$parameter]) 
                    // Route uri match
                    && $currentRoute->uri() == $menuLinkRoute->uri() 
                    // Current route Parameter match the parameter from Menu Link
                    && \Request::route()->parameter($parameter) == $menuLinksParams[$parameter]
                ) {
                    $paramsMatch = true;
                } else {
                    $paramsMatch = false;
                    continue;
                }
            }
        }

        // There may be cases where there is no parameters in routes but both route uri matches
        if (!$menuLinkRoute->parameterNames() && $currentRoute->uri() == $menuLinkRoute->uri()) {
            $paramsMatch = true;
        }

        //set MenuLink as active if route parameters's number match
        $uriWithoutParams = trim(preg_replace('@\{.*?\}@', '*', $menuLinkRoute->uri()));

        if ($paramsMatch && (Request::is($uriWithoutParams) || Request::is($uriWithoutParams."/*")) ) {
            array_push($currentMenuLinkIDs, $menuLink->menuLinkID);

            // append its parents too
            foreach (self::parentID($menuLink->menuLinkID) as $parentID) {
                array_push($currentMenuLinkIDs, $parentID);
            }
        }
    }
private static function matchRoute(&$currentMenuLinkIDs, $menuLink, $currentRoute, $menuLinkRoute)
    {
        $menuLinksParams = self::decodeParams($menuLink->params);

        //add language parameter on non-default languages
        if (App::getLocale() != Language::getDefault('slug')) {
            $menuLinksParams['lang'] = App::getLocale();
        }

        //validate params
        $paramsMatch = true;

        if ($menuLinkRoute->parameterNames()) {
            $paramsMatch = false;
            foreach ($menuLinkRoute->parameterNames() as $parameter) {
                if (// Current route parameter is present in MenuLink route
                    isset($menuLinksParams[$parameter]) 
                    // Route uri match
                    && $currentRoute->uri() == $menuLinkRoute->uri() 
                    // Current route Parameter match the parameter from Menu Link
                    && \Request::route()->parameter($parameter) == $menuLinksParams[$parameter]
                ) {
                    $paramsMatch = true;
                } else {
                    $paramsMatch = false;
                    continue;
                }
            }
        }

        // There may be cases where there is no parameters in routes but both route uri matches
        if (!$menuLinkRoute->parameterNames() && $currentRoute->uri() == $menuLinkRoute->uri()) {
            $paramsMatch = true;
        }

        //set MenuLink as active if route parameters's number match
        $uriWithoutParams = trim(preg_replace('@\{.*?\}@', '*', $menuLinkRoute->uri()));

        if ($paramsMatch && (Request::is($uriWithoutParams) || Request::is($uriWithoutParams."/*")) ) {
            array_push($currentMenuLinkIDs, $menuLink->menuLinkID);

            // append its parents too
            foreach (self::parentID($menuLink->menuLinkID) as $parentID) {
                array_push($currentMenuLinkIDs, $parentID);
            }
        }
    }
private static function matchRoute ( & $ currentMenuLinkIDs , $ menuLink , $ currentRoute , $ menuLinkRoute ) { $ menuLinksParams = self :: decodeParams ( $ menuLink -> params ) ; //add language parameter on non-default languages if ( App :: getLocale ( ) != Language :: getDefault ( 'slug' ) ) { $ menuLinksParams [ 'lang' ] = App :: getLocale ( ) ; } //validate params $ paramsMatch = true ; if ( $ menuLinkRoute -> parameterNames ( ) ) { $ paramsMatch = false ; foreach ( $ menuLinkRoute -> parameterNames ( ) as $ parameter ) { if ( // Current route parameter is present in MenuLink route isset ( $ menuLinksParams [ $ parameter ] ) // Route uri match && $ currentRoute -> uri ( ) == $ menuLinkRoute -> uri ( ) // Current route Parameter match the parameter from Menu Link && \ Request :: route ( ) -> parameter ( $ parameter ) == $ menuLinksParams [ $ parameter ] ) { $ paramsMatch = true ; } else { $ paramsMatch = false ; continue ; } } } // There may be cases where there is no parameters in routes but both route uri matches if ( ! $ menuLinkRoute -> parameterNames ( ) && $ currentRoute -> uri ( ) == $ menuLinkRoute -> uri ( ) ) { $ paramsMatch = true ; } //set MenuLink as active if route parameters's number match $ uriWithoutParams = trim ( preg_replace ( '@\{.*?\}@' , '*' , $ menuLinkRoute -> uri ( ) ) ) ; if ( $ paramsMatch && ( Request :: is ( $ uriWithoutParams ) || Request :: is ( $ uriWithoutParams . "/*" ) ) ) { array_push ( $ currentMenuLinkIDs , $ menuLink -> menuLinkID ) ; // append its parents too foreach ( self :: parentID ( $ menuLink -> menuLinkID ) as $ parentID ) { array_push ( $ currentMenuLinkIDs , $ parentID ) ; } } }
Match route based on current menulink and route

@param  array  $currentMenuLinkIDs
@param  object $menuLink
@param  object $currentRoute
@param  object $menuLinkRoute
@throws \Exception
Match route based on current menulink and route