You are here

public function FarmFormatJSON::getResourceReference in farmOS 7

File

modules/farm/farm_api/src/RestWS/Format/FarmFormatJSON.php, line 18

Class

FarmFormatJSON
Overrides the default restws response with a custom farmOS one.

Namespace

Drupal\farm_api\RestWS\Format

Code

public function getResourceReference($resource, $id) {
  $return = parent::getResourceReference($resource, $id);

  // If the resource is a taxonomy term, show the term name alongside its ID.
  if ($resource == 'taxonomy_term') {
    $term = taxonomy_term_load($id);
    if (!empty($term)) {
      $return['name'] = $term->name;
    }
  }
  return $return;
}