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 relationship types.
15 * @package CiviCRM_APIv3
19 * Create relationship type.
21 * @param array $params
22 * Array per getfields metadata.
26 function civicrm_api3_relationship_type_create($params) {
28 // @todo should we when id is empty?
29 if (!isset($params['label_a_b']) && !empty($params['name_a_b'])) {
30 $params['label_a_b'] = $params['name_a_b'];
33 if (!isset($params['label_b_a']) && !empty($params['name_b_a'])) {
34 $params['label_b_a'] = $params['name_b_a'];
37 return _civicrm_api3_basic_create(_civicrm_api3_get_BAO(__FUNCTION__
), $params, 'RelationshipType');
41 * Adjust Metadata for Create action.
43 * The metadata is used for setting defaults, documentation & validation.
45 * @param array $params
46 * Array of parameters determined by getfields.
48 function _civicrm_api3_relationship_type_create_spec(&$params) {
49 $params['name_a_b']['api.required'] = 1;
50 $params['name_b_a']['api.required'] = 1;
51 $params['is_active']['api.default'] = 1;
55 * Get all relationship types.
57 * @param array $params
61 function civicrm_api3_relationship_type_get($params) {
62 return _civicrm_api3_basic_get(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
66 * Delete a relationship type.
68 * @param array $params
73 function civicrm_api3_relationship_type_delete($params) {
74 return _civicrm_api3_basic_delete(_civicrm_api3_get_BAO(__FUNCTION__
), $params);
78 * Get list defaults for relationship types.
80 * @see _civicrm_api3_generic_getlist_defaults
82 * @param array $request
86 function _civicrm_api3_relationship_type_getlist_defaults($request) {
88 'label_field' => 'label_a_b',
89 'search_field' => 'label_a_b',