protected function findRouteByRequest(ServerRequestInterface $request, $groupUriPath, array $passedParameters = array())
    {
        // loop the group and find.
        foreach($this->storage as $route)
        {
            $result = $route->match($request, $groupUriPath);

            $remainingPath = $route->getRemainingPath($groupUriPath);

            $hasSubroutes = $route->hasSubroutes();

            // if have found, or to do a deeper search
            if(($result['route'] != false) || ($result['continue'] === true && ($remainingPath != '' && $hasSubroutes)))
            {
                $executionPriority = $route->hasSubroutes() && $route->hasExecution() && $remainingPath == '';

                // 1. if found. and no more subroute. OR
                // 2. has subroutes but, has execution,
                if(!$route->hasSubroutes() || $executionPriority)
                {
                    // prepare the final parameter by merging the passed parameter, with result parameter.
                    $params = array_merge($passedParameters, $result['parameter']);

                    return array(
                        'route'=> $result['route'],
                        'parameter'=> $params,
                        'continue'=> $result['continue']);
                }
                else
                {
                    // if has passed parameter.
                    $passedParameters = array_merge(count($result['parameter']) > 0 ? $result['parameter'] : array(), $passedParameters);

                    $subrouteResult = $route->getSubroutes()->findRouteByRequest($request, $remainingPath, $passedParameters);

                    // if found. else. continue on this group.
                    if($subrouteResult['route'] != false)
                        return $subrouteResult;
                }
            }
        }

        if($this->failRoute)
            return array('route' => $this->findRoute($this->failRoute), 'parameter' => array('request' => $request), 'continue' => false);

        // false default.
        return array('route'=> false, 'parameter'=> array(), 'continue' => false);
    }
protected function findRouteByRequest(ServerRequestInterface $request, $groupUriPath, array $passedParameters = array())
    {
        // loop the group and find.
        foreach($this->storage as $route)
        {
            $result = $route->match($request, $groupUriPath);

            $remainingPath = $route->getRemainingPath($groupUriPath);

            $hasSubroutes = $route->hasSubroutes();

            // if have found, or to do a deeper search
            if(($result['route'] != false) || ($result['continue'] === true && ($remainingPath != '' && $hasSubroutes)))
            {
                $executionPriority = $route->hasSubroutes() && $route->hasExecution() && $remainingPath == '';

                // 1. if found. and no more subroute. OR
                // 2. has subroutes but, has execution,
                if(!$route->hasSubroutes() || $executionPriority)
                {
                    // prepare the final parameter by merging the passed parameter, with result parameter.
                    $params = array_merge($passedParameters, $result['parameter']);

                    return array(
                        'route'=> $result['route'],
                        'parameter'=> $params,
                        'continue'=> $result['continue']);
                }
                else
                {
                    // if has passed parameter.
                    $passedParameters = array_merge(count($result['parameter']) > 0 ? $result['parameter'] : array(), $passedParameters);

                    $subrouteResult = $route->getSubroutes()->findRouteByRequest($request, $remainingPath, $passedParameters);

                    // if found. else. continue on this group.
                    if($subrouteResult['route'] != false)
                        return $subrouteResult;
                }
            }
        }

        if($this->failRoute)
            return array('route' => $this->findRoute($this->failRoute), 'parameter' => array('request' => $request), 'continue' => false);

        // false default.
        return array('route'=> false, 'parameter'=> array(), 'continue' => false);
    }
protected function findRouteByRequest ( ServerRequestInterface $ request , $ groupUriPath , array $ passedParameters = array ( ) ) { // loop the group and find. foreach ( $ this -> storage as $ route ) { $ result = $ route -> match ( $ request , $ groupUriPath ) ; $ remainingPath = $ route -> getRemainingPath ( $ groupUriPath ) ; $ hasSubroutes = $ route -> hasSubroutes ( ) ; // if have found, or to do a deeper search if ( ( $ result [ 'route' ] != false ) || ( $ result [ 'continue' ] === true && ( $ remainingPath != '' && $ hasSubroutes ) ) ) { $ executionPriority = $ route -> hasSubroutes ( ) && $ route -> hasExecution ( ) && $ remainingPath == '' ; // 1. if found. and no more subroute. OR // 2. has subroutes but, has execution, if ( ! $ route -> hasSubroutes ( ) || $ executionPriority ) { // prepare the final parameter by merging the passed parameter, with result parameter. $ params = array_merge ( $ passedParameters , $ result [ 'parameter' ] ) ; return array ( 'route' => $ result [ 'route' ] , 'parameter' => $ params , 'continue' => $ result [ 'continue' ] ) ; } else { // if has passed parameter. $ passedParameters = array_merge ( count ( $ result [ 'parameter' ] ) > 0 ? $ result [ 'parameter' ] : array ( ) , $ passedParameters ) ; $ subrouteResult = $ route -> getSubroutes ( ) -> findRouteByRequest ( $ request , $ remainingPath , $ passedParameters ) ; // if found. else. continue on this group. if ( $ subrouteResult [ 'route' ] != false ) return $ subrouteResult ; } } } if ( $ this -> failRoute ) return array ( 'route' => $ this -> findRoute ( $ this -> failRoute ) , 'parameter' => array ( 'request' => $ request ) , 'continue' => false ) ; // false default. return array ( 'route' => false , 'parameter' => array ( ) , 'continue' => false ) ; }
A recursivable functionality to find route under this routing group, by the given request instance.
@param ServerRequestInterface $request
@param string $groupUriPath
@param array $passedParameters - highly otional.
@return array
{route: boolean|Route, parameter: array, continue: boolean}
A recursivable functionality to find route under this routing group by the given request instance .