You are here

protected function RESTServer::render in Services 7.3

Render results using formatter.

Parameters

array $formatter: Formatter definition

$result: Value to be rendered

Return value

string Rendered result

2 calls to RESTServer::render()
MockRESTServer::protectedRender in servers/rest_server/tests/rest_server_mock_classes.inc
RESTServer::handle in servers/rest_server/includes/RESTServer.inc
Handles the call to the REST server

File

servers/rest_server/includes/RESTServer.inc, line 457
Class for handling REST calls.

Class

RESTServer
@file Class for handling REST calls.

Code

protected function render($formatter, $result) {
  if (!isset($formatter['formatter class']) || array_search('ServicesFormatterInterface', class_implements($formatter['formatter class'])) === FALSE) {
    return services_error('Formatter is invalid.', 500);
  }
  $formatter_object = new $formatter['formatter class']();
  return $formatter_object
    ->render($result);
}