class FarmFormatJSON in farmOS 7
Overrides the default restws response with a custom farmOS one.
This leverages xautoload for PSR-4 loading.
@package Drupal\farm_api\RestWs\Format
Hierarchy
- class \Drupal\farm_api\RestWS\Format\FarmFormatJSON extends \RestWSFormatJSON
Expanded class hierarchy of FarmFormatJSON
See also
farm_api_restws_format_info_alter()
File
- modules/
farm/ farm_api/ src/ RestWS/ Format/ FarmFormatJSON.php, line 16
Namespace
Drupal\farm_api\RestWS\FormatView source
class FarmFormatJSON extends RestWSFormatJSON {
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;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FarmFormatJSON:: |
public | function |