/**
* @param string $entity
* @param array $result
+ * @return string|array|null
*/
function _civicrm_api3_deprecation_check($entity, $result = array()) {
- $apiFile = 'api/v3/' . _civicrm_api_get_camel_name($entity) . '.php';
- if (CRM_Utils_File::isIncludable($apiFile)) {
- require_once $apiFile;
- }
- $entity = _civicrm_api_get_entity_name_from_camel($entity);
- $fnName = "_civicrm_api3_{$entity}_deprecation";
- if (function_exists($fnName)) {
- return $fnName($result);
+ if ($entity) {
+ $apiFile = 'api/v3/' . _civicrm_api_get_camel_name($entity) . '.php';
+ if (CRM_Utils_File::isIncludable($apiFile)) {
+ require_once $apiFile;
+ }
+ $entity = _civicrm_api_get_entity_name_from_camel($entity);
+ $fnName = "_civicrm_api3_{$entity}_deprecation";
+ if (function_exists($fnName)) {
+ return $fnName($result);
+ }
}
}
}
}
+ function isActionDeprecated(action) {
+ return !!(typeof actions.deprecated === 'object' && actions.deprecated[action]);
+ }
+
function renderAction(option) {
- if (actions.deprecated && actions.deprecated[option.id]) {
- return '<span class="strikethrough">' + option.text + '</span>';
- }
- return option.text;
+ return isActionDeprecated(option.id) ? '<span class="strikethrough">' + option.text + '</span>' : option.text;
}
/**
}
function onChangeAction(action) {
- if (actions.deprecated && actions.deprecated[action]) {
+ if (isActionDeprecated(action)) {
CRM.alert(actions.deprecated[action], action + ' deprecated');
}
}