src/Router/Router.php
public function handle( $requestUri )
    {
        $url = $this->_di->getService( "url" );

        /**
         * Remove the uri prefix from the request uri
         * (the uri prefix is added when route is created)
         */
        $requestUri = str_replace( $url->getUriPrefix(), "", $requestUri );

        $request_route = $this->_createRoute( ["uri" => $requestUri] );

        /**
         * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
         */
        //$request_route->setUri( $url->get( $request_route->getUri() ) );

        $request_route_uri_fragments = explode( "/", $request_route->getUri() );

        foreach ($this->_routeDefinitions as $routeDefinition)
        {
            $route = call_user_func($routeDefinition);

            /**
             * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
             */
            //$route->setUri( $url->get( $route->getUri() ) );

            $route_uri_fragments = explode( "/", $route->getUri() );

            /**
             * Check if request uri and route uri has the same number of fragments.
             * If not, continue to next route.
             */
            if ( count($route_uri_fragments) != count($request_route_uri_fragments) )
            {
                continue;
            }

            $params = array();

            /**
             * Compare every fragment of the uris
             */
            for ( $i = 0; $i < count($route_uri_fragments); $i++ )
            {
                /**
                 * Parameters are not compared
                 */
                if ( $route_uri_fragments[$i] == "{param}" )
                {
                    $params[] = $request_route_uri_fragments[$i];

                    continue;
                }

                /**
                 * If a fragment is not equal -> continue to next route
                 */
                if ( $route_uri_fragments[$i] != $request_route_uri_fragments[$i] )
                {
                    continue 2;
                }
            }

            $route->setParams( $params );

            /**
             * We have a match!
             */
            $this->_matchRoute = $route;

            return;
        }

        /**
         * No match :(
         * If not found route has been set -> set as out match route
         */
        if ( isset($this->_notFoundRoute) )
        {
            $this->_matchRoute = $this->_notFoundRoute;

            return;
        }

        /**
         * With no other options, we set the match route to a default route
         */
        $this->_matchRoute = new Route();
    }
public function handle( $requestUri )
    {
        $url = $this->_di->getService( "url" );

        /**
         * Remove the uri prefix from the request uri
         * (the uri prefix is added when route is created)
         */
        $requestUri = str_replace( $url->getUriPrefix(), "", $requestUri );

        $request_route = $this->_createRoute( ["uri" => $requestUri] );

        /**
         * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
         */
        //$request_route->setUri( $url->get( $request_route->getUri() ) );

        $request_route_uri_fragments = explode( "/", $request_route->getUri() );

        foreach ($this->_routeDefinitions as $routeDefinition)
        {
            $route = call_user_func($routeDefinition);

            /**
             * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
             */
            //$route->setUri( $url->get( $route->getUri() ) );

            $route_uri_fragments = explode( "/", $route->getUri() );

            /**
             * Check if request uri and route uri has the same number of fragments.
             * If not, continue to next route.
             */
            if ( count($route_uri_fragments) != count($request_route_uri_fragments) )
            {
                continue;
            }

            $params = array();

            /**
             * Compare every fragment of the uris
             */
            for ( $i = 0; $i < count($route_uri_fragments); $i++ )
            {
                /**
                 * Parameters are not compared
                 */
                if ( $route_uri_fragments[$i] == "{param}" )
                {
                    $params[] = $request_route_uri_fragments[$i];

                    continue;
                }

                /**
                 * If a fragment is not equal -> continue to next route
                 */
                if ( $route_uri_fragments[$i] != $request_route_uri_fragments[$i] )
                {
                    continue 2;
                }
            }

            $route->setParams( $params );

            /**
             * We have a match!
             */
            $this->_matchRoute = $route;

            return;
        }

        /**
         * No match :(
         * If not found route has been set -> set as out match route
         */
        if ( isset($this->_notFoundRoute) )
        {
            $this->_matchRoute = $this->_notFoundRoute;

            return;
        }

        /**
         * With no other options, we set the match route to a default route
         */
        $this->_matchRoute = new Route();
    }
public function handle ( $ requestUri ) { $ url = $ this -> _di -> getService ( "url" ) ; /**
         * Remove the uri prefix from the request uri
         * (the uri prefix is added when route is created)
         */ $ requestUri = str_replace ( $ url -> getUriPrefix ( ) , "" , $ requestUri ) ; $ request_route = $ this -> _createRoute ( [ "uri" => $ requestUri ] ) ; /**
         * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
         */ //$request_route->setUri( $url->get( $request_route->getUri() ) ); $ request_route_uri_fragments = explode ( "/" , $ request_route -> getUri ( ) ) ; foreach ( $ this -> _routeDefinitions as $ routeDefinition ) { $ route = call_user_func ( $ routeDefinition ) ; /**
             * Passing the uri to the get function in the url service to make sure the uri:s have a consistent format
             */ //$route->setUri( $url->get( $route->getUri() ) ); $ route_uri_fragments = explode ( "/" , $ route -> getUri ( ) ) ; /**
             * Check if request uri and route uri has the same number of fragments.
             * If not, continue to next route.
             */ if ( count ( $ route_uri_fragments ) != count ( $ request_route_uri_fragments ) ) { continue ; } $ params = array ( ) ; /**
             * Compare every fragment of the uris
             */ for ( $ i = 0 ; $ i < count ( $ route_uri_fragments ) ; $ i ++ ) { /**
                 * Parameters are not compared
                 */ if ( $ route_uri_fragments [ $ i ] == "{param}" ) { $ params [ ] = $ request_route_uri_fragments [ $ i ] ; continue ; } /**
                 * If a fragment is not equal -> continue to next route
                 */ if ( $ route_uri_fragments [ $ i ] != $ request_route_uri_fragments [ $ i ] ) { continue 2 ; } } $ route -> setParams ( $ params ) ; /**
             * We have a match!
             */ $ this -> _matchRoute = $ route ; return ; } /**
         * No match :(
         * If not found route has been set -> set as out match route
         */ if ( isset ( $ this -> _notFoundRoute ) ) { $ this -> _matchRoute = $ this -> _notFoundRoute ; return ; } /**
         * With no other options, we set the match route to a default route
         */ $ this -> _matchRoute = new Route ( ) ; }
Match a request uri with the route uris registered in this service
Match a request uri with the route uris registered in this service