/** * Converts data given to a string using renderer selected during before(). * * @param mixed $data * @throws HTTP_Exception_500 */ protected function _render_response_data($data) { $success = FALSE; // Render response body $body = call_user_func(RESTful_Response::get_renderer($this->_preferred_response_content_type), $data); if ($body !== FALSE) { $this->response->body($body); } else { throw HTTP_Exception::factory(500, 'RESPONSE_RENDERER_FAILURE'); } }
<?php defined('SYSPATH') or die('No direct script access.'); RESTful_Request::register_parser('application/json', 'RESTful_Request_Parser_JSON::parse'); RESTful_Request::register_parser('application/php-serialized', 'RESTful_Request_Parser_PHP::parse'); RESTful_Request::register_parser('application/x-www-form-urlencoded', 'RESTful_Request_Parser_URLENC::parse'); RESTful_Request::register_parser('application/x-www-form-urlencoded; charset=UTF-8', 'RESTful_Request_Parser_URLENC::parse'); //In order to make work HMVC requests RESTful_Request::register_parser('text/plain', 'RESTful_Request_Parser_PLAIN::parse'); RESTful_Response::register_renderer('application/json', 'RESTful_Response_Renderer_JSON::render'); RESTful_Response::register_renderer('application/php-serialized', 'RESTful_Response_Renderer_PHP::render'); RESTful_Response::register_renderer('application/php-serialized-array', 'RESTful_Response_Renderer_PHP_Array::render'); RESTful_Response::register_renderer('application/php-serialized-object', 'RESTful_Response_Renderer_PHP_Object::render'); RESTful_Response::register_renderer('text/php-printr', 'RESTful_Response_Renderer_PRINTR::render'); RESTful_Response::register_renderer('text/plain', 'RESTful_Response_Renderer_PLAIN::render');