Created
September 1, 2017 16:46
-
-
Save jchamb/d07a5dcd74d251b6d3ecf9379e4d29a8 to your computer and use it in GitHub Desktop.
ZF2 convert all request data to an array from a controller
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getRequestData() | |
{ | |
if( empty($this->request) ) | |
$this->request = $this->getRequest(); | |
$post = $this->request->getPost()->toArray(); | |
$get = $this->request->getQuery()->toArray(); | |
$headers = $this->request->getHeaders()->toArray(); | |
$body = $this->request->getContent() !== '' | |
? json_decode($this->request->getContent(), true) | |
: []; | |
return array_merge($headers, $get, $post, $body); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment