Issue #2912780: Add a hook that fires when sensor data is POSTed

This commit is contained in:
Michael Stenta 2017-09-29 10:21:41 -04:00
parent 002e74ed35
commit 6e957d14b6
2 changed files with 46 additions and 0 deletions

View File

@ -0,0 +1,43 @@
<?php
/**
* @file
* Hooks provided by farm_sensor_listener.
*
* This file contains no working PHP code; it exists to provide additional
* documentation for doxygen as well as to document hooks in the standard
* Drupal manner.
*/
/**
* @defgroup farm_sensor_listener Farm sensor module integrations.
*
* Module integrations with the farm_sensor_listener module.
*/
/**
* @defgroup farm_sensor_listener_hooks Farm sensor's hooks
* @{
* Hooks that can be implemented by other modules in order to extend farm_sensor_listener.
*/
/**
* Do more with sensor data after it has been stored to the database.
*
* @param FarmAsset $sensor
* The sensor asset.
* @param string $key
* The measurement name (ie: value, sensor1, sensor2, temperature, etc).
* @param string $value
* The sensor value.
*
* @return array
* Returns a build array to be merged into the sensor asset view page.
*/
function hook_farm_sensor_listener_data($sensor, $key, $value) {
}
/**
* @}
*/

View File

@ -238,6 +238,9 @@ function farm_sensor_listener_process_data($sensor, $data) {
// Enter the reading into the {farm_sensor_data} table.
drupal_write_record('farm_sensor_data', $row);
// Invoke hook_farm_sensor_listener_data().
module_invoke_all('farm_sensor_listener_data', $sensor, $key, $value);
}
}