public function readRoutes()
    {
        // routes begin with method
        $this->__method = $this->detectMethod();

        // find all matching routes
        $try_routes = array();
        foreach($this->__routes as $route) {
            // correct request type
            if(substr($route,0,strlen($this->__method)) == $this->__method) {
                $params = $this->routeParams($route);    
                if ($params !== false && $this->hasParams($params)) {
                    if (!isset($try_routes[count($params)])) {
                        $try_routes[count($params)] = array();
                    }
                    $try_routes[count($params)][] = $route;
                } elseif ($params === false) {
                    $try_routes[0] = array($route);
                }
            }
        }
        
        // use the route with the most parameters
        // set class variables to parameters
        $num_params = array_keys($try_routes);
        rsort($num_params);
        $this->__route_stem = 'unknownRequest';
        if (count($num_params) > 0) {
            $longest = $num_params[0];
            $best_route = array_pop($try_routes[$longest]);
            $this->__route_stem = $this->__method;
            if ($longest > 0) {
                foreach($this->routeParams($best_route) as $param) {
                    $this->$param = $this->form->$param;
                    $this->__route_stem .= '_'.$param;
                }
            }
        }
    }
public function readRoutes()
    {
        // routes begin with method
        $this->__method = $this->detectMethod();

        // find all matching routes
        $try_routes = array();
        foreach($this->__routes as $route) {
            // correct request type
            if(substr($route,0,strlen($this->__method)) == $this->__method) {
                $params = $this->routeParams($route);    
                if ($params !== false && $this->hasParams($params)) {
                    if (!isset($try_routes[count($params)])) {
                        $try_routes[count($params)] = array();
                    }
                    $try_routes[count($params)][] = $route;
                } elseif ($params === false) {
                    $try_routes[0] = array($route);
                }
            }
        }
        
        // use the route with the most parameters
        // set class variables to parameters
        $num_params = array_keys($try_routes);
        rsort($num_params);
        $this->__route_stem = 'unknownRequest';
        if (count($num_params) > 0) {
            $longest = $num_params[0];
            $best_route = array_pop($try_routes[$longest]);
            $this->__route_stem = $this->__method;
            if ($longest > 0) {
                foreach($this->routeParams($best_route) as $param) {
                    $this->$param = $this->form->$param;
                    $this->__route_stem .= '_'.$param;
                }
            }
        }
    }
public function readRoutes ( ) { // routes begin with method $ this -> __method = $ this -> detectMethod ( ) ; // find all matching routes $ try_routes = array ( ) ; foreach ( $ this -> __routes as $ route ) { // correct request type if ( substr ( $ route , 0 , strlen ( $ this -> __method ) ) == $ this -> __method ) { $ params = $ this -> routeParams ( $ route ) ; if ( $ params !== false && $ this -> hasParams ( $ params ) ) { if ( ! isset ( $ try_routes [ count ( $ params ) ] ) ) { $ try_routes [ count ( $ params ) ] = array ( ) ; } $ try_routes [ count ( $ params ) ] [ ] = $ route ; } elseif ( $ params === false ) { $ try_routes [ 0 ] = array ( $ route ) ; } } } // use the route with the most parameters // set class variables to parameters $ num_params = array_keys ( $ try_routes ) ; rsort ( $ num_params ) ; $ this -> __route_stem = 'unknownRequest' ; if ( count ( $ num_params ) > 0 ) { $ longest = $ num_params [ 0 ] ; $ best_route = array_pop ( $ try_routes [ $ longest ] ) ; $ this -> __route_stem = $ this -> __method ; if ( $ longest > 0 ) { foreach ( $ this -> routeParams ( $ best_route ) as $ param ) { $ this -> $ param = $ this -> form -> $ param ; $ this -> __route_stem .= '_' . $ param ; } } } }
Parse request info and determine which route to use
Parse request info and determine which route to use