protected function getRouteByUrl($url)
    {
        $url = str_replace($this->rootNode, '', $url);
        $nodes = explode(self::ROUTE_SEPARATOR, $url);
        $routeTree = $this->routeTree;
        $ids = [];
        $route = [];
        $countNodes = count($nodes);
        $uid = null;

        // Lookup route ...
        for ($i = 0; $i < $countNodes; ++$i) {

            // Is regular route way/node ?
            if (is_array($routeTree) && isset($routeTree[$nodes[$i]])) {
                $routeTree = $routeTree[$nodes[$i]];
            } elseif (preg_match('/{{(.*)}}/i', key($routeTree), $variable) > 0) {
                // maybe its a variable node value
                $nodes[$i] = '{{'.$variable[1].'}}';
                $id = $this->extractId($variable[1]);
                if ($id !== null) {
                    $uid = $id;
                }

                $ids[] = $nodes[$i];
                $routeTree = $routeTree[$nodes[$i]];
            } else {
                throw new Doozr_Base_Presenter_Rest_Exception(
                    'Route for URL "'.$url.'" seems wrong. It could not be resolved.',
                    400
                );
            }

            $route[] = $nodes[$i];

            if ($i === ($countNodes - 1)) {
                if (is_object($routeTree) === true) {
                    // Inject Ids for reverse lookup
                    /* @var $routeTree Doozr_Base_Presenter_Rest_Config */
                    $routeTree
                        ->id($uid)
                        ->ids($ids)
                        ->url($url)
                        ->realRoute($route)
                        ->rootNode($this->rootNode);
                } else {
                    // In this case we ended up before we got configuration!
                    throw new Doozr_Base_Presenter_Rest_Exception(
                        'Route for URL "'.$url.'" seems incomplete.',
                        406
                    );
                }
            }
        }

        return $routeTree;
    }
protected function getRouteByUrl($url)
    {
        $url = str_replace($this->rootNode, '', $url);
        $nodes = explode(self::ROUTE_SEPARATOR, $url);
        $routeTree = $this->routeTree;
        $ids = [];
        $route = [];
        $countNodes = count($nodes);
        $uid = null;

        // Lookup route ...
        for ($i = 0; $i < $countNodes; ++$i) {

            // Is regular route way/node ?
            if (is_array($routeTree) && isset($routeTree[$nodes[$i]])) {
                $routeTree = $routeTree[$nodes[$i]];
            } elseif (preg_match('/{{(.*)}}/i', key($routeTree), $variable) > 0) {
                // maybe its a variable node value
                $nodes[$i] = '{{'.$variable[1].'}}';
                $id = $this->extractId($variable[1]);
                if ($id !== null) {
                    $uid = $id;
                }

                $ids[] = $nodes[$i];
                $routeTree = $routeTree[$nodes[$i]];
            } else {
                throw new Doozr_Base_Presenter_Rest_Exception(
                    'Route for URL "'.$url.'" seems wrong. It could not be resolved.',
                    400
                );
            }

            $route[] = $nodes[$i];

            if ($i === ($countNodes - 1)) {
                if (is_object($routeTree) === true) {
                    // Inject Ids for reverse lookup
                    /* @var $routeTree Doozr_Base_Presenter_Rest_Config */
                    $routeTree
                        ->id($uid)
                        ->ids($ids)
                        ->url($url)
                        ->realRoute($route)
                        ->rootNode($this->rootNode);
                } else {
                    // In this case we ended up before we got configuration!
                    throw new Doozr_Base_Presenter_Rest_Exception(
                        'Route for URL "'.$url.'" seems incomplete.',
                        406
                    );
                }
            }
        }

        return $routeTree;
    }
protected function getRouteByUrl ( $ url ) { $ url = str_replace ( $ this -> rootNode , '' , $ url ) ; $ nodes = explode ( self :: ROUTE_SEPARATOR , $ url ) ; $ routeTree = $ this -> routeTree ; $ ids = [ ] ; $ route = [ ] ; $ countNodes = count ( $ nodes ) ; $ uid = null ; // Lookup route ... for ( $ i = 0 ; $ i < $ countNodes ; ++ $ i ) { // Is regular route way/node ? if ( is_array ( $ routeTree ) && isset ( $ routeTree [ $ nodes [ $ i ] ] ) ) { $ routeTree = $ routeTree [ $ nodes [ $ i ] ] ; } elseif ( preg_match ( '/{{(.*)}}/i' , key ( $ routeTree ) , $ variable ) > 0 ) { // maybe its a variable node value $ nodes [ $ i ] = '{{' . $ variable [ 1 ] . '}}' ; $ id = $ this -> extractId ( $ variable [ 1 ] ) ; if ( $ id !== null ) { $ uid = $ id ; } $ ids [ ] = $ nodes [ $ i ] ; $ routeTree = $ routeTree [ $ nodes [ $ i ] ] ; } else { throw new Doozr_Base_Presenter_Rest_Exception ( 'Route for URL "' . $ url . '" seems wrong. It could not be resolved.' , 400 ) ; } $ route [ ] = $ nodes [ $ i ] ; if ( $ i === ( $ countNodes - 1 ) ) { if ( is_object ( $ routeTree ) === true ) { // Inject Ids for reverse lookup /* @var $routeTree Doozr_Base_Presenter_Rest_Config */ $ routeTree -> id ( $ uid ) -> ids ( $ ids ) -> url ( $ url ) -> realRoute ( $ route ) -> rootNode ( $ this -> rootNode ) ; } else { // In this case we ended up before we got configuration! throw new Doozr_Base_Presenter_Rest_Exception ( 'Route for URL "' . $ url . '" seems incomplete.' , 406 ) ; } } } return $ routeTree ; }
Returns the route matched by URL including configuration and extracted Ids ...
We do only throws exceptions here instead of sending header directives like 404 405 406.
This is responsibility of the implementing application cause here too high level.

@param string $url The URL to return route for.

@author Benjamin Carl <opensource@clickalicious.de>

@return Doozr_Base_Presenter_Rest_Config|false The configuration if route could be revsolved,
false if route could not be resolved

@throws Doozr_Base_Presenter_Rest_Exception
Returns the route matched by URL including configuration and extracted Ids ... We do only throws exceptions here instead of sending header directives like 404 405 406 . This is responsibility of the implementing application cause here too high level .