public function handleRequest($request)
    {
        if (empty($this->catchAll)) {
            try {
                list($route, $params) = $request->resolve();
            } catch (UrlNormalizerRedirectException $e) {
                $url = $e->url;
                if (is_array($url)) {
                    if (isset($url[0])) {
                        // ensure the route is absolute
                        $url[0] = '/' . ltrim($url[0], '/');
                    }
                    $url += $request->getQueryParams();
                }

                return $this->getResponse()->redirect(Url::to($url, $e->scheme), $e->statusCode);
            }
        } else {
            $route = $this->catchAll[0];
            $params = $this->catchAll;
            unset($params[0]);
        }
        try {
            Yii::debug("Route requested: '$route'", __METHOD__);
            $this->requestedRoute = $route;
            $result = $this->runAction($route, $params);
            if ($result instanceof Response) {
                return $result;
            }

            $response = $this->getResponse();
            if ($result !== null) {
                $response->data = $result;
            }

            return $response;
        } catch (InvalidRouteException $e) {
            throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
        }
    }
public function handleRequest($request)
    {
        if (empty($this->catchAll)) {
            try {
                list($route, $params) = $request->resolve();
            } catch (UrlNormalizerRedirectException $e) {
                $url = $e->url;
                if (is_array($url)) {
                    if (isset($url[0])) {
                        
                        $url[0] = '/' . ltrim($url[0], '/');
                    }
                    $url += $request->getQueryParams();
                }

                return $this->getResponse()->redirect(Url::to($url, $e->scheme), $e->statusCode);
            }
        } else {
            $route = $this->catchAll[0];
            $params = $this->catchAll;
            unset($params[0]);
        }
        try {
            Yii::debug("Route requested: '$route'", __METHOD__);
            $this->requestedRoute = $route;
            $result = $this->runAction($route, $params);
            if ($result instanceof Response) {
                return $result;
            }

            $response = $this->getResponse();
            if ($result !== null) {
                $response->data = $result;
            }

            return $response;
        } catch (InvalidRouteException $e) {
            throw new NotFoundHttpException(Yii::t('yii', 'Page not found.'), $e->getCode(), $e);
        }
    }
public function handleRequest ( $ request ) { if ( empty ( $ this -> catchAll ) ) { try { list ( $ route , $ params ) = $ request -> resolve ( ) ; } catch ( UrlNormalizerRedirectException $ e ) { $ url = $ e -> url ; if ( is_array ( $ url ) ) { if ( isset ( $ url [ 0 ] ) ) { // ensure the route is absolute $ url [ 0 ] = '/' . ltrim ( $ url [ 0 ] , '/' ) ; } $ url += $ request -> getQueryParams ( ) ; } return $ this -> getResponse ( ) -> redirect ( Url :: to ( $ url , $ e -> scheme ) , $ e -> statusCode ) ; } } else { $ route = $ this -> catchAll [ 0 ] ; $ params = $ this -> catchAll ; unset ( $ params [ 0 ] ) ; } try { Yii :: debug ( "Route requested: '$route'" , __METHOD__ ) ; $ this -> requestedRoute = $ route ; $ result = $ this -> runAction ( $ route , $ params ) ; if ( $ result instanceof Response ) { return $ result ; } $ response = $ this -> getResponse ( ) ; if ( $ result !== null ) { $ response -> data = $ result ; } return $ response ; } catch ( InvalidRouteException $ e ) { throw new NotFoundHttpException ( Yii :: t ( 'yii' , 'Page not found.' ) , $ e -> getCode ( ) , $ e ) ; } }
Handles the specified request.
@param Request $request the request to be handled
@return Response the resulting response
@throws NotFoundHttpException if the requested route is invalid
Handles the specified request .