Neos\Flow\Property\TypeConverter\MediaTypeConverter::convertMediaType PHP Méthode

convertMediaType() protected méthode

Converts the given request body according to the specified media type Override this method in your custom TypeConverter to support additional media types
protected convertMediaType ( string $requestBody, string $mediaType ) : array
$requestBody string the raw request body
$mediaType string the configured media type (for example "application/json")
Résultat array
    protected function convertMediaType($requestBody, $mediaType)
    {
        $mediaTypeParts = MediaTypes::parseMediaType($mediaType);
        if (!isset($mediaTypeParts['subtype']) || $mediaTypeParts['subtype'] === '') {
            return [];
        }
        $result = [];
        switch ($mediaTypeParts['subtype']) {
            case 'json':
            case 'x-json':
            case 'javascript':
            case 'x-javascript':
                $result = json_decode($requestBody, true);
                if ($result === null) {
                    return [];
                }
                break;
            case 'xml':
                $entityLoaderValue = libxml_disable_entity_loader(true);
                try {
                    $xmlElement = new \SimpleXMLElement(urldecode($requestBody), LIBXML_NOERROR);
                    libxml_disable_entity_loader($entityLoaderValue);
                } catch (\Exception $exception) {
                    libxml_disable_entity_loader($entityLoaderValue);
                    return [];
                }
                $result = Arrays::convertObjectToArray($xmlElement);
                break;
            case 'x-www-form-urlencoded':
            default:
                parse_str($requestBody, $result);
                break;
        }
        return $result;
    }