1 <?php
2 /**
3 * Accepts form encoded strings and converts them
4 * to a valid PHP array via {@link parse_str()}.
5 * Use together with {@link RESTfulServer} to submit
6 * data via POST or PUT.
7 *
8 * Example when using cURL on commandline:
9 * <code>
10 * curl -d "Name=This is a new record" http://host/api/v1/(DataObject)
11 * curl -X PUT -d "Name=This is an updated record" http://host/api/v1/(DataObject)/1
12 * </code>
13 *
14 * @todo Format response form encoded as well - currently uses XMLDataFormatter
15 *
16 * @author Cam Spiers <camspiers at gmail dot com>
17 *
18 * @package sapphire
19 * @subpackage formatters
20 */
21 class FormEncodedDataFormatter extends XMLDataFormatter {
22
23 public function supportedExtensions() {
24 return array(
25 );
26 }
27
28 public function supportedMimeTypes() {
29 return array(
30 'application/x-www-form-urlencoded'
31 );
32 }
33
34 public function convertStringToArray($strData) {
35 $postArray = array();
36 parse_str($strData, $postArray);
37 return $postArray;
38 //TODO: It would be nice to implement this function in Convert.php
39 //return Convert::querystr2array($strData);
40 }
41
42 }
43 ?>