3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * This api exposes CiviCRM option groups.
15 * OptionGroups are containers for option values.
17 * @package CiviCRM_APIv3
23 * @param array $params
27 function civicrm_api3_option_group_get($params) {
28 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
32 * Create/update option group.
34 * @param array $params
35 * Array per getfields metadata.
39 function civicrm_api3_option_group_create($params) {
40 // Use deprecated BAO method in APIv3 for legacy support. APIv4 uses new writeRecords method.
41 $bao = CRM_Core_BAO_OptionGroup
::add($params);
42 civicrm_api('option_value', 'getfields', ['version' => 3, 'cache_clear' => 1]);
44 _civicrm_api3_object_to_array($bao, $values[$bao->id
]);
45 return civicrm_api3_create_success($values, $params, 'OptionGroup', 'create', $bao);
49 * Adjust Metadata for Create action.
51 * The metadata is used for setting defaults, documentation & validation.
53 * @param array $params
54 * Array of parameters determined by getfields.
56 function _civicrm_api3_option_group_create_spec(&$params) {
57 $params['name']['api.unique'] = 1;
58 $params['is_active']['api.default'] = TRUE;
62 * Delete an existing Option Group.
64 * This method is used to delete any existing OptionGroup given its id.
66 * @param array $params
72 function civicrm_api3_option_group_delete($params) {
73 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);