Router.php
public function route($uri = null)
    {
        if ($uri === null) {
            $uri = $this->getAppUri();
        }
        //$uri = ltrim(preg_replace('/^([^&]*)&.*$/', '$1', $uri), '/');
        
        $urlElements = parse_url($uri);
        $uri      = isset($urlElements['path'])     ? $urlElements['path']     : '';
        $query    = isset($urlElements['query'])    ? $urlElements['query']    : null;
        $fragment = isset($urlElements['fragment']) ? $urlElements['fragment'] : null;
        $urlTab = explode('/', trim($uri, ' /'));
        $request = Container::getRequest();
        $request->setUri($uri);
        $request->setBaseUrl($this->getBaseUrl());
        $controller = array_shift($urlTab);
        $action = array_shift($urlTab);
        $request->setController($controller ? $controller : self::DEFAULT_CONTROLLER);
        $request->setAction($action ? $action : self::DEFAULT_ACTION);
        while (count($urlTab)) {
            $key = trim(array_shift($urlTab));
            $value = array_shift($urlTab);
            if ($value !== null) {
                $request->setParam($key, $value);
            }
        }
        if ($query !== null) {
            $params = null;
            parse_str($query, $params);
            foreach ($params as $key => $value) {
                $request->setParam($key, $value);
            }
        }
        
        return $this;
    }
public function route($uri = null)
    {
        if ($uri === null) {
            $uri = $this->getAppUri();
        }
        //$uri = ltrim(preg_replace('/^([^&]*)&.*$/', '$1', $uri), '/');
        
        $urlElements = parse_url($uri);
        $uri      = isset($urlElements['path'])     ? $urlElements['path']     : '';
        $query    = isset($urlElements['query'])    ? $urlElements['query']    : null;
        $fragment = isset($urlElements['fragment']) ? $urlElements['fragment'] : null;
        $urlTab = explode('/', trim($uri, ' /'));
        $request = Container::getRequest();
        $request->setUri($uri);
        $request->setBaseUrl($this->getBaseUrl());
        $controller = array_shift($urlTab);
        $action = array_shift($urlTab);
        $request->setController($controller ? $controller : self::DEFAULT_CONTROLLER);
        $request->setAction($action ? $action : self::DEFAULT_ACTION);
        while (count($urlTab)) {
            $key = trim(array_shift($urlTab));
            $value = array_shift($urlTab);
            if ($value !== null) {
                $request->setParam($key, $value);
            }
        }
        if ($query !== null) {
            $params = null;
            parse_str($query, $params);
            foreach ($params as $key => $value) {
                $request->setParam($key, $value);
            }
        }
        
        return $this;
    }
public function route ( $ uri = null ) { if ( $ uri === null ) { $ uri = $ this -> getAppUri ( ) ; } //$uri = ltrim(preg_replace('/^([^&]*)&.*$/', '$1', $uri), '/'); $ urlElements = parse_url ( $ uri ) ; $ uri = isset ( $ urlElements [ 'path' ] ) ? $ urlElements [ 'path' ] : '' ; $ query = isset ( $ urlElements [ 'query' ] ) ? $ urlElements [ 'query' ] : null ; $ fragment = isset ( $ urlElements [ 'fragment' ] ) ? $ urlElements [ 'fragment' ] : null ; $ urlTab = explode ( '/' , trim ( $ uri , ' /' ) ) ; $ request = Container :: getRequest ( ) ; $ request -> setUri ( $ uri ) ; $ request -> setBaseUrl ( $ this -> getBaseUrl ( ) ) ; $ controller = array_shift ( $ urlTab ) ; $ action = array_shift ( $ urlTab ) ; $ request -> setController ( $ controller ? $ controller : self :: DEFAULT_CONTROLLER ) ; $ request -> setAction ( $ action ? $ action : self :: DEFAULT_ACTION ) ; while ( count ( $ urlTab ) ) { $ key = trim ( array_shift ( $ urlTab ) ) ; $ value = array_shift ( $ urlTab ) ; if ( $ value !== null ) { $ request -> setParam ( $ key , $ value ) ; } } if ( $ query !== null ) { $ params = null ; parse_str ( $ query , $ params ) ; foreach ( $ params as $ key => $ value ) { $ request -> setParam ( $ key , $ value ) ; } } return $ this ; }
Update Request with params from url
@param string $uri
@return Router
Update Request with params from url