Commit c7eec9f6 by yeran

change the get post data way from php://input to $this->request->getPost()

1 parent ecf085a9
Showing with 5 additions and 4 deletions
...@@ -57,8 +57,9 @@ abstract class Controller extends PhalconController ...@@ -57,8 +57,9 @@ abstract class Controller extends PhalconController
} }
} }
if (empty($input)) { if (empty($input)) {
$input_string = file_get_contents('php://input'); // $input_string = file_get_contents('php://input');
$input_data = json_decode($input_string, true); // $input_data = json_decode($input_string, true);
$input_data = $this->request->getPost();
if (is_array($input_data)) { if (is_array($input_data)) {
$input = $input_data; $input = $input_data;
} else { } else {
...@@ -142,7 +143,7 @@ abstract class Controller extends PhalconController ...@@ -142,7 +143,7 @@ abstract class Controller extends PhalconController
} }
} else { } else {
$params = $this->request->getHeader($name); $params = $this->request->getHeader($name);
if($params){ if ($params) {
return $params; return $params;
} }
if (false !== $is_validate) { if (false !== $is_validate) {
...@@ -186,9 +187,9 @@ abstract class Controller extends PhalconController ...@@ -186,9 +187,9 @@ abstract class Controller extends PhalconController
* Q: Why make the `php://input` encapsulation? * Q: Why make the `php://input` encapsulation?
* A: I want to use it in service mode, which is impossible to pass data via `php://input` between processes. * A: I want to use it in service mode, which is impossible to pass data via `php://input` between processes.
* This is not exactly the same as the Phalcon's implementation. * This is not exactly the same as the Phalcon's implementation.
* @see \Phalcon\Http\Request::getRawBody()
* @return string * @return string
* @codeCoverageIgnore * @codeCoverageIgnore
* @see \Phalcon\Http\Request::getRawBody()
*/ */
protected function getRawPhpInput() protected function getRawPhpInput()
{ {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!