services_views.resource.inc file, line no. 83, $item->$field_label = $field->theme($row);
I want to apply htmlspecialchars_decode() function to the output returned by theme() function without modifying services_views.resource.inc file.

Comments

mandarmbhagwat78’s picture

Seems no option than to change into services_views.resource.inc.
$item->$field_label = htmlspecialchars_decode($field->theme($row));

Alternative plz.

ygerasimov’s picture

Priority: Critical » Normal
Status: Active » Fixed

I would try two other scenarios:
1. add htmlspecialchars_decode in theming function in case it is displayed in services call
2. override output of the call using hook_services_request_postprocess_alter()

mandarmbhagwat78’s picture

Where can I find the definition of hook_services_request_postprocess_alter()?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

bc’s picture

I fixed it like this:

/**
 * Implements hook_services_request_postprocess_alter().
 *
 * For services_views resources, set numeric types correctly for nice JSON.
 */
function gnl_fields_services_request_postprocess_alter($controller, $args, &$result) {
  if ($controller['callback'] === 'services_views_retrieve') {
    foreach ((array) $result as $res) {
      foreach ($res as &$field) {
        if (is_numeric($field) ) {
          $field = floatval($field);
        }
      }
    }
  }
}

It'd be nice for this to be part of services or services_views but I'm not quite sure where it'd best fit.