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 Case.
15 * @package CiviCRM_APIv3
19 * Create or update case type.
21 * @param array $params
24 * @throws API_Exception
28 function civicrm_api3_case_type_create($params) {
29 civicrm_api3_verify_mandatory($params, _civicrm_api3_get_DAO(__FUNCTION__
));
31 $result = _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'CaseType');
32 return _civicrm_api3_case_type_get_formatResult($result);
36 * Retrieve case types.
38 * @param array $params
41 * case types keyed by id
43 function civicrm_api3_case_type_get($params) {
44 if (!empty($params['options']) && !empty($params['options']['is_count'])) {
45 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
47 $caseTypes = _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
48 // format case type, to fetch xml definition
49 $options = _civicrm_api3_get_options_from_params($params);
50 return _civicrm_api3_case_type_get_formatResult($caseTypes, $options);
56 * @param array $result
57 * @param array $options
60 * @throws \CRM_Core_Exception
62 function _civicrm_api3_case_type_get_formatResult(&$result, $options = []) {
63 foreach ($result['values'] as $key => &$caseType) {
64 if (!empty($caseType['definition']) ||
empty($options['return']) ||
!empty($options['return']['definition'])) {
65 $caseType +
= ['definition' => NULL];
66 CRM_Case_BAO_CaseType
::formatOutputDefinition($caseType['definition'], $caseType);
68 $caseType['is_forkable'] = CRM_Case_BAO_CaseType
::isForkable($caseType['id']);
69 $caseType['is_forked'] = CRM_Case_BAO_CaseType
::isForked($caseType['id']);
75 * Function to delete case type.
77 * @param array $params
78 * Array including id of CaseType to delete.
83 function civicrm_api3_case_type_delete($params) {
84 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);