From d71dccbcf387a5895739a9db0b9e1c7cbb55d9d0 Mon Sep 17 00:00:00 2001 From: Steffen Vogel Date: Thu, 22 Jul 2010 12:08:01 +0200 Subject: [PATCH] added HTTP method dependent action (REST pattern) --- backend/lib/Dispatcher.php | 2 +- backend/lib/View/HTTP/Request.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/backend/lib/Dispatcher.php b/backend/lib/Dispatcher.php index bebdbae..e796f81 100644 --- a/backend/lib/Dispatcher.php +++ b/backend/lib/Dispatcher.php @@ -114,7 +114,7 @@ class Dispatcher { * execute application */ public function run() { - $action = ($this->view->request->getParameter('action')) ? 'get' : $this->view->request->getParameter('action'); // default action + $action = ($this->view->request->getParameter('action')) ? strtolower($this->view->request->getMethod()) : $this->view->request->getParameter('action'); // default action $this->controller->run($action); // run controllers actions (usually CRUD: http://de.wikipedia.org/wiki/CRUD) diff --git a/backend/lib/View/HTTP/Request.php b/backend/lib/View/HTTP/Request.php index ac4eb07..06f4ac3 100644 --- a/backend/lib/View/HTTP/Request.php +++ b/backend/lib/View/HTTP/Request.php @@ -39,7 +39,7 @@ class Request { * * @link http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html */ - public $method; + protected $method; /** * constructor @@ -63,7 +63,7 @@ class Request { * setter & getter */ public function getHeader($header) { return $this->headers[$header]; } - + public function getMethod() { return $this->method; }; public function getParameter($name, $method = 'get') { return (isset($this->parameters[$method][$name])) ? $this->parameters[$method][$name] : NULL; }