lithium\net\http\Router::process PHP 메소드

process() 공개 정적인 메소드

Wrapper method which takes a Request object, parses it through all attached Route objects, assigns the resulting parameters to the Request object, and returns it.
public static process ( Request $request ) : Request
$request lithium\action\Request
리턴 lithium\action\Request Returns a copy of the request with parameters applied.
    public static function process($request)
    {
        if (!($result = static::parse($request))) {
            return $request;
        }
        return $result;
    }

Usage Example

예제 #1
0
 /**
  * Returns the corresponding params for a given URL and an optional request
  * method.
  *
  * Examples:
  * ```
  * 1: li3 route show /foo
  * 2: li3 route show post /foo/bar/1
  * 3: li3 route show /test
  * 4: li3 route show /test --env=production
  * ```
  *
  * Will return outputs similar to:
  *
  * ```
  * 1: {"controller":"foo","action":"index"	}
  * 2: {"controller":"foo","action":"bar","args":["1"]}
  * 3: {"controller":"lithium\\test\\Controller","action":"index"}
  * 4: {"controller":"test","action":"index"}
  * ```
  *
  * @return void
  */
 public function show()
 {
     $url = join(" ", $this->request->params['args']);
     $method = 'GET';
     if (!$url) {
         $this->error('Please provide a valid URL');
     }
     if (preg_match('/^(GET|POST|PUT|DELETE|HEAD|OPTIONS) (.+)/i', $url, $matches)) {
         $method = strtoupper($matches[1]);
         $url = $matches[2];
     }
     $request = new Request(compact('url') + array('env' => array('REQUEST_METHOD' => $method)));
     $result = Router::process($request);
     $this->out($result->params ? json_encode($result->params) : "No route found.");
 }
All Usage Examples Of lithium\net\http\Router::process