/**
*
+ * @param $msg
* @param array $data
- *
- * @throws API_Exception
* @return array
- * <type>
*/
function civicrm_api3_create_error($msg, $data = array()) {
$data['is_error'] = 1;
/**
* Load the DAO of the entity
+ * @param $entity
+ * @return bool
*/
function _civicrm_api3_load_DAO($entity) {
$dao = _civicrm_api3_get_DAO($entity);
/**
* Recursive function to explode value-separated strings into arrays
- *
+ * @param $values
*/
function _civicrm_api3_separate_values(&$values) {
$sp = CRM_Core_DAO::VALUE_SEPARATOR;
* others that use the query object. Note that this function passes permission information in.
* The others don't
*
- * * Ideally this would be merged with _civicrm_get_query_object but we need to resolve differences in what the
+ * Ideally this would be merged with _civicrm_get_query_object but we need to resolve differences in what the
* 2 variants call
* @param $entity
* @param array $params
* @param array $params
* @param string $mode
* @param string $entity
- * @return CRM_Core_DAO
- * query object
+ * @return array(CRM_Core_DAO|CRM_Contact_BAO_Query)
*/
function _civicrm_api3_get_query_object($params, $mode, $entity) {
$options = _civicrm_api3_get_options_from_params($params, TRUE, $entity, 'get');
/**
* build fields array. This is the array of fields as it relates to the given DAO
* returns unique fields as keys by default but if set but can return by DB fields
+ * @param $bao
+ * @param bool $unique
+ * @return
*/
function _civicrm_api3_build_fields_array(&$bao, $unique = TRUE) {
$fields = $bao->fields();
/**
* build fields array. This is the array of fields as it relates to the given DAO
* returns unique fields as keys by default but if set but can return by DB fields
- * @param CRM_Core_BAO $bao
+ * @param CRM_Core_DAO $bao
*
* @return mixed
*/
*
* @return array
*
- * @static void
- * @access public
*/
function _civicrm_api3_dao_to_array($dao, $params = NULL, $uniqueFields = TRUE, $entity = "", $autoFind = TRUE) {
$result = array();
* @param array|bool $uniqueFields
*
* @return array
- * @static void
- * @access public
*/
function _civicrm_api3_object_to_array(&$dao, &$values, $uniqueFields = FALSE) {
/**
* Wrapper for _civicrm_object_to_array when api supports unique fields
+ * @param $dao
+ * @param $values
+ * @return array
*/
function _civicrm_api3_object_to_array_unique_fields(&$dao, &$values) {
return _civicrm_api3_object_to_array($dao, $values, TRUE);
* @return bool
* Sshould the missing fields be returned as an array (core error created as default)
* true if all fields present, depending on $result a core error is created of an array of missing fields is returned
- * @access public
*/
function _civicrm_api3_check_required_fields($params, $daoName, $return = FALSE) {
//@deprecated - see notes
}
if (!empty($fieldInfo['api.unique'])) {
$params['entity'] = $entity;
- _civicrm_api3_validate_uniquekey($params, $fieldName, $fieldInfo);
+ _civicrm_api3_validate_unique_key($params, $fieldName);
}
}
}
/**
* Validate foreign constraint fields being passed into API.
*
- * @param array $params
- * Params from civicrm_api.
+ * @param mixed $fieldValue
* @param string $fieldName
* Uniquename of field being checked.
* @param array $fieldInfo
* Array of fields from getfields function.
- * @throws Exception
+ * @throws \API_Exception
*/
function _civicrm_api3_validate_constraint(&$fieldValue, &$fieldName, &$fieldInfo) {
$dao = new $fieldInfo['FKClassName'];
$dao->selectAdd();
$dao->selectAdd('id');
if (!$dao->find()) {
- throw new Exception("$fieldName is not valid : " . $fieldValue);
+ throw new API_Exception("$fieldName is not valid : " . $fieldValue);
}
}
* Params from civicrm_api.
* @param string $fieldName
* Uniquename of field being checked.
- * @param $fieldInfo
- * Array of fields from getfields function.
* @throws Exception
*/
-function _civicrm_api3_validate_uniquekey(&$params, &$fieldName, &$fieldInfo) {
+function _civicrm_api3_validate_unique_key(&$params, &$fieldName) {
list($fieldValue, $op) = _civicrm_api3_field_value_check($params, $fieldName);
if (strpos($op, 'NULL') !== FALSE || strpos($op, 'EMPTY') !== FALSE) {
return;
/**
* Return an array of fields for a given entity - this is the same as the BAO function but
* fields are prefixed with 'custom_' to represent api params
+ * @param $entity
+ * @param array $params
+ * @return array
*/
function _civicrm_api_get_custom_fields($entity, &$params) {
$entity = _civicrm_api_get_camel_name($entity);
}
return $ret;
}
+
/**
* Translate the custom field data_type attribute into a std 'type'
+ * @param $dataType
+ * @return
*/
function _getStandardTypeFromCustomDataType($dataType) {
$mapping = array(
* If multiple aliases the last takes precedence
*
* Function also swaps unique fields for non-unique fields & vice versa.
+ * @param $apiRequest
+ * @param $fields
*/
function _civicrm_api3_swap_out_aliases(&$apiRequest, $fields) {
foreach ($fields as $field => $values) {
/**
* Validate & swap out any pseudoconstants / options
*
- * @param array $params: api parameters
- * @param string $entity: api entity name
- * @param string $fieldName: field name used in api call (not necessarily the canonical name)
- * @param array $fieldInfo: getfields meta-data
+ * @param mixed $fieldValue
+ * @param string $entity : api entity name
+ * @param string $fieldName : field name used in api call (not necessarily the canonical name)
+ * @param array $fieldInfo : getfields meta-data
+ * @throws \API_Exception
*/
function _civicrm_api3_api_match_pseudoconstant(&$fieldValue, $entity, $fieldName, $fieldInfo) {
$options = CRM_Utils_Array::value('options', $fieldInfo);