Library/Think/Http/Router.class.php
/**
     * Get URL for named route
     * @param  string            $name   The name of the route
     * @param  array             $params Associative array of URL parameter names and replacement values
     * @throws \RuntimeException If named route not found
     * @return string            The URL for the given route populated with provided replacement values
     */
Get URL for named route
@param  string            $name   The name of the route
@param  array             $params Associative array of URL parameter names and replacement values
@throws \RuntimeException If named route not found
@return string            The URL for the given route populated with provided replacement values
Get URL for named route @param string $name The name of the route @param array $params Associative array of URL parameter names and replacement values @throws \ RuntimeException If named route not found @return string The URL for the given route populated with provided replacement values
public function urlFor($name, $params = []) {
        if (!$this->hasNamedRoute($name)) {
            throw new \RuntimeException('Named route not found for name: ' . $name);
        }
        $search = [];
        foreach ($params as $key => $value) {
            $search[] = '#:' . preg_quote($key, '#') . '\+?(?!\w)#';
        }
        $route = $this->getNamedRoute($name);
        $pattern = preg_replace($search, $params, $route->getPattern());
        return $route->getDomain() . preg_replace('#\(/?:.+\)|\(|\)|\\\\#', '', $pattern);
    }
public function urlFor ( $ name , $ params = [ ] ) { if ( ! $ this -> hasNamedRoute ( $ name ) ) { throw new \ RuntimeException ( 'Named route not found for name: ' . $ name ) ; } $ search = [ ] ; foreach ( $ params as $ key => $ value ) { $ search [ ] = '#:' . preg_quote ( $ key , '#' ) . '\+?(?!\w)#' ; } $ route = $ this -> getNamedRoute ( $ name ) ; $ pattern = preg_replace ( $ search , $ params , $ route -> getPattern ( ) ) ; return $ route -> getDomain ( ) . preg_replace ( '#\(/?:.+\)|\(|\)|\\\\#' , '' , $ pattern ) ; }
Get URL for named route
 @param  string            $name   The name of the route
 @param  array             $params Associative array of URL parameter names and replacement values
 @throws \RuntimeException If named route not found
 @return string            The URL for the given route populated with provided replacement values
Get URL for named route @param string $name The name of the route @param array $params Associative array of URL parameter names and replacement values @throws \ RuntimeException If named route not found @return string The URL for the given route populated with provided replacement values
//Remove remnants of unpopulated, trailing optional pattern segments, escaped special characters