2009-03-29 01:51:38 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Accepts form encoded strings and converts them
|
|
|
|
* to a valid PHP array via {@link parse_str()}.
|
|
|
|
*
|
|
|
|
* Example when using cURL on commandline:
|
|
|
|
* <code>
|
|
|
|
* curl -d "Name=This is a new record" http://host/api/v1/(DataObject)
|
|
|
|
* curl -X PUT -d "Name=This is an updated record" http://host/api/v1/(DataObject)/1
|
|
|
|
* </code>
|
|
|
|
*
|
|
|
|
* @todo Format response form encoded as well - currently uses XMLDataFormatter
|
|
|
|
*
|
|
|
|
* @author Cam Spiers <camspiers at gmail dot com>
|
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2009-03-29 01:51:38 +01:00
|
|
|
* @subpackage formatters
|
|
|
|
*/
|
|
|
|
class FormEncodedDataFormatter extends XMLDataFormatter {
|
|
|
|
|
|
|
|
public function supportedExtensions() {
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function supportedMimeTypes() {
|
|
|
|
return array(
|
|
|
|
'application/x-www-form-urlencoded'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function convertStringToArray($strData) {
|
2012-12-08 12:20:20 +01:00
|
|
|
$postArray = array();
|
|
|
|
parse_str($strData, $postArray);
|
|
|
|
return $postArray;
|
2009-03-29 01:51:38 +01:00
|
|
|
//TODO: It would be nice to implement this function in Convert.php
|
|
|
|
//return Convert::querystr2array($strData);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|