protected function convertResourceToPlainText($format, Resource $resource)
    {
        switch ($format) {
            case 'xml':
                return (string)$resource->getXML()->asXml();
            case 'json':
                return (string)$resource;
            default:
                throw new NotAcceptableHttpException();
        }
    }