Created
June 6, 2014 19:54
-
-
Save kitsunet/a496d3423221f44bc91d to your computer and use it in GitHub Desktop.
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
| protected function decodeBodyArguments($body, $mediaType) { | |
| switch (MediaTypes::trimMediaType($mediaType)) { | |
| case 'application/json': | |
| case 'application/x-javascript': | |
| case 'text/javascript': | |
| case 'text/x-javascript': | |
| case 'text/x-json': | |
| $arguments = array(); | |
| $decoded_json_body = json_decode($body, TRUE); | |
| if ($decoded_json_body !== NULL) { | |
| $arguments['decoded_json_body'] = $decoded_json_body; | |
| } | |
| break; | |
| case 'text/xml': | |
| case 'application/xml': | |
| try { | |
| $xmlElement = new \SimpleXMLElement(urldecode($body), LIBXML_NOERROR); | |
| } catch (\Exception $e) { | |
| return array(); | |
| } | |
| $arguments = Arrays::convertObjectToArray($xmlElement); | |
| break; | |
| case 'application/x-www-form-urlencoded': | |
| default: | |
| parse_str($body, $arguments); | |
| break; | |
| } | |
| return $arguments; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment