copyValues($params); $dao->save(); if (!empty($dao->id)) { $values = [$dao->id => $entities]; _civicrm_api3_object_to_array($dao, $values[$dao->id]); return civicrm_api3_create_success($values, $params, 'LocBlock', 'create', $dao); } throw New API_Exception('Unable to create LocBlock. Please check your params.'); } /** * Returns array of loc_blocks matching a set of one or more properties. * * @param array $params * Array of one or more valid property_name=>value pairs. If $params is set. * as null, all loc_blocks will be returned (default limit is 25). * * @return array * API result array. */ function civicrm_api3_loc_block_get($params) { $options = _civicrm_api3_get_options_from_params($params); // If a return param has been set then fetch the appropriate fk objects // This is a helper because api chaining does not work with a key like 'email_2'. if (!empty($options['return'])) { unset($params['return']); $values = []; $items = ['address', 'email', 'phone', 'im']; $returnAll = !empty($options['return']['all']); foreach (_civicrm_api3_basic_get('CRM_Core_DAO_LocBlock', $params, FALSE) as $val) { foreach ($items as $item) { foreach (['', '_2'] as $suf) { $key = $item . $suf; if (!empty($val[$key . '_id']) && ($returnAll || !empty($options['return'][$key]))) { $val[$key] = civicrm_api($item, 'getsingle', ['version' => 3, 'id' => $val[$key . '_id']]); } } } $values[$val['id']] = $val; } return civicrm_api3_create_success($values, $params, 'LocBlock', 'get'); } return _civicrm_api3_basic_get('CRM_Core_DAO_LocBlock', $params); } /** * Delete an existing LocBlock. * * @param array $params * Array containing id of the record to be deleted. * * @return array * API result array. */ function civicrm_api3_loc_block_delete($params) { return _civicrm_api3_basic_delete('CRM_Core_DAO_LocBlock', $params); }