1
<?php
2

3
namespace SilverStripe\RestfulServer\DataFormatter;
4

5
/**
6
 * Accepts form encoded strings and converts them
7
 * to a valid PHP array via {@link parse_str()}.
8
 *
9
 * Example when using cURL on commandline:
10
 * <code>
11
 * curl -d "Name=This is a new record" http://host/api/v1/(DataObject)
12
 * curl -X PUT -d "Name=This is an updated record" http://host/api/v1/(DataObject)/1
13
 * </code>
14
 *
15
 * @todo Format response form encoded as well - currently uses XMLDataFormatter
16
 *
17
 * @author Cam Spiers <camspiers at gmail dot com>
18
 */
19
class FormEncodedDataFormatter extends XMLDataFormatter
20
{
21

22 0
    public function supportedExtensions()
23
    {
24
        return array(
25
        );
26
    }
27

28 1
    public function supportedMimeTypes()
29
    {
30
        return array(
31 1
            'application/x-www-form-urlencoded'
32
        );
33
    }
34

35 1
    public function convertStringToArray($strData)
36
    {
37 1
        $postArray = array();
38 1
        parse_str($strData, $postArray);
39 1
        return $postArray;
40
        //TODO: It would be nice to implement this function in Convert.php
41
        //return Convert::querystr2array($strData);
42
    }
43
}

Read our documentation on viewing source code .

Loading