public function _as($name)
    {
        if (empty($name)) return $this;
        $name = rtrim($this->getGroupAs() . str_replace('/', '.', strtolower($name)), '.');
//        if (array_key_exists($name, $this->routes)) {
//            throw new \Exception("Route name ($name) already registered.");
//        }

        $patt = $this->patt;
        $pram = $this->prams;
        // Merge group parameters with route parameters.
        if ($this->isGroup) {
            $patt = array_merge($this->pattGroup, $patt);
            if (count($patt) > count($pram)) {
                $pram = array_merge($this->pramsGroup, $pram);
            }
        }

        // :param
        if (count($pram)) {
            foreach ($pram as $k => $v) {
                $pram[$k] = '/:' . $v;
            }
        }

        // Replace pattern to named parameters.
        $replaced = $this->group . $this->currentUri;
        foreach ($patt as $k => $v) {
            $pos = strpos($replaced, $v);
            if ($pos !== false) {
                $replaced = substr_replace($replaced, $pram[$k], $pos, strlen($v));
            }
        }

        $this->routes[$name] = ltrim($this->removeDuplSlash(strtolower($replaced)), '/');

        return $this;
    }
public function _as($name)
    {
        if (empty($name)) return $this;
        $name = rtrim($this->getGroupAs() . str_replace('/', '.', strtolower($name)), '.');
//        if (array_key_exists($name, $this->routes)) {
//            throw new \Exception("Route name ($name) already registered.");
//        }

        $patt = $this->patt;
        $pram = $this->prams;
        // Merge group parameters with route parameters.
        if ($this->isGroup) {
            $patt = array_merge($this->pattGroup, $patt);
            if (count($patt) > count($pram)) {
                $pram = array_merge($this->pramsGroup, $pram);
            }
        }

        // :param
        if (count($pram)) {
            foreach ($pram as $k => $v) {
                $pram[$k] = '/:' . $v;
            }
        }

        // Replace pattern to named parameters.
        $replaced = $this->group . $this->currentUri;
        foreach ($patt as $k => $v) {
            $pos = strpos($replaced, $v);
            if ($pos !== false) {
                $replaced = substr_replace($replaced, $pram[$k], $pos, strlen($v));
            }
        }

        $this->routes[$name] = ltrim($this->removeDuplSlash(strtolower($replaced)), '/');

        return $this;
    }
public function _as ( $ name ) { if ( empty ( $ name ) ) return $ this ; $ name = rtrim ( $ this -> getGroupAs ( ) . str_replace ( '/' , '.' , strtolower ( $ name ) ) , '.' ) ; //        if (array_key_exists($name, $this->routes)) {
 //            throw new \Exception("Route name ($name) already registered.");
 //        }
 $ patt = $ this -> patt ; $ pram = $ this -> prams ; // Merge group parameters with route parameters.
 if ( $ this -> isGroup ) { $ patt = array_merge ( $ this -> pattGroup , $ patt ) ; if ( count ( $ patt ) > count ( $ pram ) ) { $ pram = array_merge ( $ this -> pramsGroup , $ pram ) ; } } // :param
 if ( count ( $ pram ) ) { foreach ( $ pram as $ k => $ v ) { $ pram [ $ k ] = '/:' . $ v ; } } // Replace pattern to named parameters.
 $ replaced = $ this -> group . $ this -> currentUri ; foreach ( $ patt as $ k => $ v ) { $ pos = strpos ( $ replaced , $ v ) ; if ( $ pos !== false ) { $ replaced = substr_replace ( $ replaced , $ pram [ $ k ] , $ pos , strlen ( $ v ) ) ; } } $ this -> routes [ $ name ] = ltrim ( $ this -> removeDuplSlash ( strtolower ( $ replaced ) ) , '/' ) ; return $ this ; }
Set a route name.

@param string $name
@return $this
@throws \Exception
Set a route name .