From: Coleman Watts Date: Fri, 23 Jan 2015 14:54:41 +0000 (-0500) Subject: CRM-15862 - Improve entityRef defaults and support relationship_type X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=bc255d1d6473df53a573ead86fe5fb495e3641b1;p=civicrm-core.git CRM-15862 - Improve entityRef defaults and support relationship_type --- diff --git a/api/v3/Generic/Getlist.php b/api/v3/Generic/Getlist.php index 5af1f8de61..8676ee6e98 100644 --- a/api/v3/Generic/Getlist.php +++ b/api/v3/Generic/Getlist.php @@ -34,7 +34,10 @@ function civicrm_api3_generic_getList($apiRequest) { $entity = _civicrm_api_get_entity_name_from_camel($apiRequest['entity']); $request = $apiRequest['params']; - _civicrm_api3_generic_getList_defaults($entity, $request); + // Hey api, would you like to provide default values? + $fnName = "_civicrm_api3_{$entity}_getlist_defaults"; + $defaults = function_exists($fnName) ? $fnName($request) : array(); + _civicrm_api3_generic_getList_defaults($entity, $request, $defaults); // Hey api, would you like to format the search params? $fnName = "_civicrm_api3_{$entity}_getlist_params"; @@ -67,8 +70,9 @@ function civicrm_api3_generic_getList($apiRequest) { * * @param string $entity * @param array $request + * @param array $apiDefaults */ -function _civicrm_api3_generic_getList_defaults($entity, &$request) { +function _civicrm_api3_generic_getList_defaults($entity, &$request, $apiDefaults) { $config = CRM_Core_Config::singleton(); $fields = _civicrm_api_get_fields($entity); $defaults = array( @@ -94,7 +98,7 @@ function _civicrm_api3_generic_getList_defaults($entity, &$request) { } } $resultsPerPage = CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'search_autocomplete_count', NULL, 10); - $request += $defaults; + $request += $apiDefaults + $defaults; // Default api params $params = array( 'options' => array( diff --git a/api/v3/RelationshipType.php b/api/v3/RelationshipType.php index d7b1eb516e..dc8da5a358 100644 --- a/api/v3/RelationshipType.php +++ b/api/v3/RelationshipType.php @@ -112,3 +112,16 @@ function civicrm_api3_relationship_type_get($params) { function civicrm_api3_relationship_type_delete($params) { return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params); } + +/** + * @see _civicrm_api3_generic_getlist_defaults + * + * @param array $request + * @return array + */ +function _civicrm_api3_relationship_type_getlist_defaults($request) { + return array( + 'label_field' => 'label_a_b', + 'search_field' => 'label_a_b', + ); +} \ No newline at end of file