mirror of
https://github.com/silverstripe/doc.silverstripe.org
synced 2024-10-22 17:05:50 +02:00
7ecbf49ac9
git-svn-id: http://svn.silverstripe.com/projects/ss2doc/branches/v2@117896 467b73ca-7a2a-4603-9d3b-597d59a354a9
43 lines
1.1 KiB
PHP
43 lines
1.1 KiB
PHP
<?php
|
|
/**
|
|
* Accepts form encoded strings and converts them
|
|
* to a valid PHP array via {@link parse_str()}.
|
|
* Use together with {@link RESTfulServer} to submit
|
|
* data via POST or PUT.
|
|
*
|
|
* 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>
|
|
*
|
|
* @package sapphire
|
|
* @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) {
|
|
$postArray = array();
|
|
parse_str($strData, $postArray);
|
|
return $postArray;
|
|
//TODO: It would be nice to implement this function in Convert.php
|
|
//return Convert::querystr2array($strData);
|
|
}
|
|
|
|
}
|
|
?>
|