src/Pupcake/Router.php
public function processRouteMatchingNative($event)
    {
        $request_type = $event->props('request_type');
        $uri = $event->props('query_path');
        $route_pattern= $event->props('route_pattern');
        $result = false;
        $params = array();

        $route_pattern_length = strlen($route_pattern);
        $path_pos = strpos($route_pattern, "*path"); //see if there is *path exists
        if ($path_pos !== FALSE) {
            $first_part_of_path = substr($route_pattern, 0, $path_pos);
            if (substr($uri, 0, $path_pos) == $first_part_of_path) {
                $uri_length = strlen($uri);
                $params[":path"] = substr($uri, $path_pos, $uri_length - $path_pos);
                $route = $this->getRoute($request_type, $route_pattern);
                $route->setParams($params);
                $this->setMatchedRoute($route); 
                $result = true;
                return $result;
            }
        }

        $uri_comps = explode("/", $uri);
        $uri_comps_count = count($uri_comps);
        $route_pattern_comps = explode("/", $route_pattern);
        $route_pattern_comps_count = count($route_pattern_comps);
        if ($uri_comps_count == $route_pattern_comps_count) {
            for ($k=1;$k<$route_pattern_comps_count;$k++ ) { //we should start from index 1 since index 0 is the /
                if ($route_pattern_comps[$k][0] == ":") {
                    $token = $route_pattern_comps[$k];
                    $params[$token] = $uri_comps[$k];
                    $route_pattern_comps[$k] = "";
                    $uri_comps[$k] = "";
                }
            }

            $uri_reformed = implode("/",$uri_comps);
            $route_pattern_reformed = implode("/",$route_pattern_comps);
            $route = $this->getRoute($request_type, $route_pattern);
            $route->setParams($params);

            if ($uri_reformed == $route_pattern_reformed) {
                $results = $this->app->trigger("system.routing.route.matched", "", array('route' => $route));

                //the result can be either a boolean or an array 
                $result = true;
                if ( is_array($results) && count($results) > 0 ) {  //the result is an array
                    foreach ($results as $matched) {
                        if (!$matched) {
                            $result = false;
                            break;
                        }
                    }
                }
                else if ($results === FALSE) {
                    $result = false; 
                }

                if ($result) { 
                    $this->setMatchedRoute($route); 
                }

            }
        }

        return $result;
    }
public function processRouteMatchingNative($event)
    {
        $request_type = $event->props('request_type');
        $uri = $event->props('query_path');
        $route_pattern= $event->props('route_pattern');
        $result = false;
        $params = array();

        $route_pattern_length = strlen($route_pattern);
        $path_pos = strpos($route_pattern, "*path"); //see if there is *path exists
        if ($path_pos !== FALSE) {
            $first_part_of_path = substr($route_pattern, 0, $path_pos);
            if (substr($uri, 0, $path_pos) == $first_part_of_path) {
                $uri_length = strlen($uri);
                $params[":path"] = substr($uri, $path_pos, $uri_length - $path_pos);
                $route = $this->getRoute($request_type, $route_pattern);
                $route->setParams($params);
                $this->setMatchedRoute($route); 
                $result = true;
                return $result;
            }
        }

        $uri_comps = explode("/", $uri);
        $uri_comps_count = count($uri_comps);
        $route_pattern_comps = explode("/", $route_pattern);
        $route_pattern_comps_count = count($route_pattern_comps);
        if ($uri_comps_count == $route_pattern_comps_count) {
            for ($k=1;$k<$route_pattern_comps_count;$k++ ) { //we should start from index 1 since index 0 is the /
                if ($route_pattern_comps[$k][0] == ":") {
                    $token = $route_pattern_comps[$k];
                    $params[$token] = $uri_comps[$k];
                    $route_pattern_comps[$k] = "";
                    $uri_comps[$k] = "";
                }
            }

            $uri_reformed = implode("/",$uri_comps);
            $route_pattern_reformed = implode("/",$route_pattern_comps);
            $route = $this->getRoute($request_type, $route_pattern);
            $route->setParams($params);

            if ($uri_reformed == $route_pattern_reformed) {
                $results = $this->app->trigger("system.routing.route.matched", "", array('route' => $route));

                //the result can be either a boolean or an array 
                $result = true;
                if ( is_array($results) && count($results) > 0 ) {  //the result is an array
                    foreach ($results as $matched) {
                        if (!$matched) {
                            $result = false;
                            break;
                        }
                    }
                }
                else if ($results === FALSE) {
                    $result = false; 
                }

                if ($result) { 
                    $this->setMatchedRoute($route); 
                }

            }
        }

        return $result;
    }
public function processRouteMatchingNative ( $ event ) { $ request_type = $ event -> props ( 'request_type' ) ; $ uri = $ event -> props ( 'query_path' ) ; $ route_pattern = $ event -> props ( 'route_pattern' ) ; $ result = false ; $ params = array ( ) ; $ route_pattern_length = strlen ( $ route_pattern ) ; $ path_pos = strpos ( $ route_pattern , "*path" ) ; //see if there is *path exists if ( $ path_pos !== FALSE ) { $ first_part_of_path = substr ( $ route_pattern , 0 , $ path_pos ) ; if ( substr ( $ uri , 0 , $ path_pos ) == $ first_part_of_path ) { $ uri_length = strlen ( $ uri ) ; $ params [ ":path" ] = substr ( $ uri , $ path_pos , $ uri_length - $ path_pos ) ; $ route = $ this -> getRoute ( $ request_type , $ route_pattern ) ; $ route -> setParams ( $ params ) ; $ this -> setMatchedRoute ( $ route ) ; $ result = true ; return $ result ; } } $ uri_comps = explode ( "/" , $ uri ) ; $ uri_comps_count = count ( $ uri_comps ) ; $ route_pattern_comps = explode ( "/" , $ route_pattern ) ; $ route_pattern_comps_count = count ( $ route_pattern_comps ) ; if ( $ uri_comps_count == $ route_pattern_comps_count ) { for ( $ k = 1 ; $ k < $ route_pattern_comps_count ; $ k ++ ) { //we should start from index 1 since index 0 is the / if ( $ route_pattern_comps [ $ k ] [ 0 ] == ":" ) { $ token = $ route_pattern_comps [ $ k ] ; $ params [ $ token ] = $ uri_comps [ $ k ] ; $ route_pattern_comps [ $ k ] = "" ; $ uri_comps [ $ k ] = "" ; } } $ uri_reformed = implode ( "/" , $ uri_comps ) ; $ route_pattern_reformed = implode ( "/" , $ route_pattern_comps ) ; $ route = $ this -> getRoute ( $ request_type , $ route_pattern ) ; $ route -> setParams ( $ params ) ; if ( $ uri_reformed == $ route_pattern_reformed ) { $ results = $ this -> app -> trigger ( "system.routing.route.matched" , "" , array ( 'route' => $ route ) ) ; //the result can be either a boolean or an array  $ result = true ; if ( is_array ( $ results ) && count ( $ results ) > 0 ) { //the result is an array foreach ( $ results as $ matched ) { if ( ! $ matched ) { $ result = false ; break ; } } } else if ( $ results === FALSE ) { $ result = false ; } if ( $ result ) { $ this -> setMatchedRoute ( $ route ) ; } } } return $ result ; }
process route matching
@param Event the event object
@return boolean whether the route matched the uri or not
process route matching