Commit 1287424f authored by jaapjansma's avatar jaapjansma
Browse files

Cache clear when a data processor is changed

parent 1a326074
......@@ -6,6 +6,10 @@
* it is now also possible to output a data processor on CiviCRMs dahsboard.
* Added field outputs for simple calculations (substract and total).
# Version 1.0.7
* Build a cache clear when a data processor configuration is changed.
# Version 1.0.6
* Performance improvement by caching the data processor and the api calls.
......@@ -22,7 +26,6 @@
# Version 1.0.3
* Fixed issue with date filters.
>>>>>>> origin/performance
# Version 1.0.2
......
......@@ -24,6 +24,18 @@ class CRM_Dataprocessor_Utils_Cache {
]);
}
/**
* Clear all data processor caches.
*
* This is a helper function which contains a clear cache for all caches.
*
*/
public static function clearAllDataProcessorCaches() {
$cache = CRM_Dataprocessor_Utils_Cache::singleton();
$cache->cache->clear();
Civi\DataProcessor\Output\Api::clearCache();
}
/**
* @return \CRM_DataProcessor_Utils_Cache
*/
......
......@@ -31,6 +31,14 @@ class Api implements OutputInterface, API_ProviderInterface, EventSubscriberInte
]);
}
/**
* Flushes the caches
*/
public static function clearCache() {
$api = new Api();
$api->cache->clear();
}
/**
* Returns true when this filter has additional configuration
*
......
......@@ -36,6 +36,7 @@ function civicrm_api3_data_processor_create($params) {
}
$return = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
CRM_Dataprocessor_BAO_DataProcessor::updateAndChekStatus($return['id']);
CRM_Dataprocessor_Utils_Cache::clearAllDataProcessorCaches();
return $return;
}
......
......@@ -42,6 +42,7 @@ function civicrm_api3_data_processor_field_create($params) {
$return = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
$dataProcessorId = civicrm_api3('DataProcessorField', 'getvalue', array('id' => $return['id'], 'return' => 'data_processor_id'));
CRM_Dataprocessor_BAO_DataProcessor::updateAndChekStatus($dataProcessorId);
CRM_Dataprocessor_Utils_Cache::clearAllDataProcessorCaches();
return $return;
}
......
......@@ -42,6 +42,7 @@ function civicrm_api3_data_processor_filter_create($params) {
$return = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
$dataProcessorId = civicrm_api3('DataProcessorFilter', 'getvalue', array('id' => $return['id'], 'return' => 'data_processor_id'));
CRM_Dataprocessor_BAO_DataProcessor::updateAndChekStatus($dataProcessorId);
CRM_Dataprocessor_Utils_Cache::clearAllDataProcessorCaches();
return $return;
}
......
......@@ -43,6 +43,7 @@ function civicrm_api3_data_processor_output_create($params) {
function civicrm_api3_data_processor_output_delete($params) {
$dataProcessorId = civicrm_api3('DataProcessorOutput', 'getvalue', array('id' => $params['id'], 'return' => 'data_processor_id'));
CRM_Dataprocessor_BAO_DataProcessor::updateAndChekStatus($dataProcessorId);
CRM_Dataprocessor_Utils_Cache::clearAllDataProcessorCaches();
return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
}
......
......@@ -42,6 +42,7 @@ function civicrm_api3_data_processor_source_create($params) {
$return = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params);
$dataProcessorId = civicrm_api3('DataProcessorSource', 'getvalue', array('id' => $return['id'], 'return' => 'data_processor_id'));
CRM_Dataprocessor_BAO_DataProcessor::updateAndChekStatus($dataProcessorId);
CRM_Dataprocessor_Utils_Cache::clearAllDataProcessorCaches();
return $return;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment