Expose sensor_type and sensor_settings fields to sensor assets REST API #329

This commit is contained in:
Michael Stenta 2020-07-27 11:02:50 -04:00
commit 9f63c4f80b
2 changed files with 24 additions and 0 deletions

View File

@ -118,6 +118,8 @@ projects[restws][patch][] = "http://www.drupal.org/files/issues/2019-06-17/restw
projects[restws][patch][] = "http://www.drupal.org/files/issues/2020-03-29/restws-auth-check-2490416-12.patch"
; Fix Issue #2301237: Allow creating nodes with multi-value fields
projects[restws][patch][] = "https://www.drupal.org/files/issues/2020-05-31/2301237-34.patch"
; Fix Issue #3161113: Support fields with unknown data type.
projects[restws][patch][] = "http://www.drupal.org/files/issues/2020-07-23/3161113-6.patch"
projects[restws_field_collection][subdir] = "contrib"
projects[restws_field_collection][version] = "1.1"

View File

@ -33,6 +33,28 @@ function farm_sensor_farm_ui_entity_view_groups() {
return $groups;
}
/**
* Implements hook_entity_property_info_alter().
*/
function farm_sensor_entity_property_info_alter(&$info) {
// Add a sensor type property to sensor assets.
$info['farm_asset']['bundles']['sensor']['properties']['sensor_type'] = array(
'type' => 'text',
'label' => t('Sensor Type'),
'description' => t('The type of sensor.'),
'setter callback' => 'entity_property_verbatim_set',
);
// Add a sensor settings property to sensor assets.
$info['farm_asset']['bundles']['sensor']['properties']['sensor_settings'] = array(
'type' => 'unknown',
'label' => t('Sensor Settings'),
'description' => t('Settings for this sensor.'),
'setter callback' => 'entity_property_verbatim_set',
);
}
/**
* Implements hook_entity_load().
*/