Merge pull request #15842 from totten/master-config-backend
[civicrm-core.git] / api / v3 / OptionGroup.php
CommitLineData
6a488035 1<?php
c28e1768
CW
2/*
3 +--------------------------------------------------------------------+
a30c801b 4 | Copyright CiviCRM LLC. All rights reserved. |
c28e1768 5 | |
a30c801b
TO
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 |
c28e1768
CW
9 +--------------------------------------------------------------------+
10 */
11
12/**
13 * This api exposes CiviCRM option groups.
244bbdd8
CW
14 *
15 * OptionGroups are containers for option values.
c28e1768
CW
16 *
17 * @package CiviCRM_APIv3
c28e1768 18 */
6a488035 19
aa1b1481 20/**
61fe4988
EM
21 * Get option groups.
22 *
c490a46a 23 * @param array $params
aa1b1481
EM
24 *
25 * @return array
26 */
6a488035 27function civicrm_api3_option_group_get($params) {
6a488035
TO
28 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__), $params);
29}
30
31/**
9d32e6f7 32 * Create/update option group.
6a488035 33 *
cf470720 34 * @param array $params
9d32e6f7 35 * Array per getfields metadata.
6a488035 36 *
a6c01b45 37 * @return array
6a488035
TO
38 */
39function civicrm_api3_option_group_create($params) {
7cbde1aa 40 $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__), $params, 'OptionGroup');
cf8f0fff 41 civicrm_api('option_value', 'getfields', ['version' => 3, 'cache_clear' => 1]);
7cbde1aa 42 return $result;
6a488035
TO
43}
44
11e09c59 45/**
211e2fca
EM
46 * Adjust Metadata for Create action.
47 *
48 * The metadata is used for setting defaults, documentation & validation.
1c88e578 49 *
cf470720 50 * @param array $params
b081365f 51 * Array of parameters determined by getfields.
6a488035
TO
52 */
53function _civicrm_api3_option_group_create_spec(&$params) {
54 $params['name']['api.unique'] = 1;
801bafd7 55 $params['is_active']['api.default'] = TRUE;
6a488035 56}
4033343a 57
58/**
211e2fca 59 * Delete an existing Option Group.
4033343a 60 *
244bbdd8 61 * This method is used to delete any existing OptionGroup given its id.
4033343a 62 *
cf470720 63 * @param array $params
c28e1768 64 * [id]
4033343a 65 *
a6c01b45 66 * @return array
72b3a70c 67 * API Result Array
4033343a 68 */
69function civicrm_api3_option_group_delete($params) {
70 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__), $params);
71}