diff --git a/src/frapi/library/Frapi/Controller/Main.php b/src/frapi/library/Frapi/Controller/Main.php index 73a5f87..01c5b8f 100644 --- a/src/frapi/library/Frapi/Controller/Main.php +++ b/src/frapi/library/Frapi/Controller/Main.php @@ -36,7 +36,7 @@ class Frapi_Controller_Main * The request parameter * * The value of the superglobal $_REQUEST - * variable from the web server. + * variable from the web server plus route variables. * * @var array $request The $_REQUEST */ @@ -247,7 +247,9 @@ public function __construct($customAuthorization=null) $this->setAction($this->getParam('action')); } - $this->setFiles($_FILES); + // assign the files and params from the request + $this->setFiles($_FILES) + ->setParams($this->request); $this->authorization->setAuthorizationParams($this->getParams()); } catch (Frapi_Exception $e) { @@ -295,11 +297,12 @@ public function getFiles() * the filess variable. * * @param array $params The params to set. - * @return void + * @return Frapi_Controller_Main */ private function setFiles($params) { $this->files = $params; + return $this; } /** @@ -308,21 +311,22 @@ private function setFiles($params) * This method returns an array of the parameters * passed. * - * Is this similar to getRequest ? I have to check tmrw. - * @todo ^ * @return Mixed An array or a string of parameters */ public function getParams() { - $params = $this->request; - - /** - * This certainly isn't a pure approach however it is a very - * practical approach that will suit most people most of the times. - * - * Unhappy? Remove me. - */ + return $this->params; + } + /** + * parses the request and sets request parameters for later use + * + * @param array $params request params collected so far + * @return Frapi_Controller_Main + */ + public function setParams(array $params) + { + // read the raw input to get the request body $input = file_get_contents("php://input"); parse_str($input, $puts); @@ -371,8 +375,9 @@ public function getParams() } } - $this->request = $params; - return $this->request; + // set the total request params; combines derived request params and parsed params + $this->params = $params; + return $this; } /** @@ -386,8 +391,8 @@ public function getParams() */ public function getParam($key) { - if (isset($this->request[$key])) { - return $this->request[$key]; + if (isset($this->params[$key])) { + return $this->params[$key]; } if (isset($this->files[$key])) {