protected function getRoute($destination)
    {
        $destinationPieces = explode('/', $destination);

        $mappingNode = $this->routeMapping;
        $argValues = array();
        foreach($destinationPieces as $destinationPiece) {
            if (isset($mappingNode[$destinationPiece])) {
                $mappingNode = $mappingNode[$destinationPiece];
            } elseif (isset($mappingNode['_wildcard'])) {
                $argValues[] = $destinationPiece;
                $mappingNode = $mappingNode['_wildcard'];
            } else {
                throw new Exception("Route mapping not found for destination '{$destination}'");
            }
        }

        if (!isset($mappingNode['_mapping']) || !($mappingNode['_mapping'] instanceof Route\Mapping)) {
            throw new Exception("Route mapping not found for destination '{$destination}'");
        }

        /**
         * @var Route\Mapping $mapping;
         */
        $mapping = $mappingNode['_mapping'];

        $patternPieces = explode('/', $mapping->destinationPattern());
        $routeArgs = array();
        foreach ($patternPieces as $piece) {
            if($this->isWildcard($piece)) {
                $argName = substr($piece, 1, -1);
                $routeArgs[$argName] = array_shift($argValues);
            }
        }

        $this->validateRouteMapping($mapping);

        return new Route($mapping->controller(), $mapping->action(), $routeArgs);
    }
protected function getRoute($destination)
    {
        $destinationPieces = explode('/', $destination);

        $mappingNode = $this->routeMapping;
        $argValues = array();
        foreach($destinationPieces as $destinationPiece) {
            if (isset($mappingNode[$destinationPiece])) {
                $mappingNode = $mappingNode[$destinationPiece];
            } elseif (isset($mappingNode['_wildcard'])) {
                $argValues[] = $destinationPiece;
                $mappingNode = $mappingNode['_wildcard'];
            } else {
                throw new Exception("Route mapping not found for destination '{$destination}'");
            }
        }

        if (!isset($mappingNode['_mapping']) || !($mappingNode['_mapping'] instanceof Route\Mapping)) {
            throw new Exception("Route mapping not found for destination '{$destination}'");
        }

        /**
         * @var Route\Mapping $mapping;
         */
        $mapping = $mappingNode['_mapping'];

        $patternPieces = explode('/', $mapping->destinationPattern());
        $routeArgs = array();
        foreach ($patternPieces as $piece) {
            if($this->isWildcard($piece)) {
                $argName = substr($piece, 1, -1);
                $routeArgs[$argName] = array_shift($argValues);
            }
        }

        $this->validateRouteMapping($mapping);

        return new Route($mapping->controller(), $mapping->action(), $routeArgs);
    }
protected function getRoute ( $ destination ) { $ destinationPieces = explode ( '/' , $ destination ) ; $ mappingNode = $ this -> routeMapping ; $ argValues = array ( ) ; foreach ( $ destinationPieces as $ destinationPiece ) { if ( isset ( $ mappingNode [ $ destinationPiece ] ) ) { $ mappingNode = $ mappingNode [ $ destinationPiece ] ; } elseif ( isset ( $ mappingNode [ '_wildcard' ] ) ) { $ argValues [ ] = $ destinationPiece ; $ mappingNode = $ mappingNode [ '_wildcard' ] ; } else { throw new Exception ( "Route mapping not found for destination '{$destination}'" ) ; } } if ( ! isset ( $ mappingNode [ '_mapping' ] ) || ! ( $ mappingNode [ '_mapping' ] instanceof Route \ Mapping ) ) { throw new Exception ( "Route mapping not found for destination '{$destination}'" ) ; } /**
         * @var Route\Mapping $mapping;
         */ $ mapping = $ mappingNode [ '_mapping' ] ; $ patternPieces = explode ( '/' , $ mapping -> destinationPattern ( ) ) ; $ routeArgs = array ( ) ; foreach ( $ patternPieces as $ piece ) { if ( $ this -> isWildcard ( $ piece ) ) { $ argName = substr ( $ piece , 1 , - 1 ) ; $ routeArgs [ $ argName ] = array_shift ( $ argValues ) ; } } $ this -> validateRouteMapping ( $ mapping ) ; return new Route ( $ mapping -> controller ( ) , $ mapping -> action ( ) , $ routeArgs ) ; }
Get Route for given destination

@param string $destination Destination

@throws \Shade\Exception

@return Route
Get Route for given destination