3 * Test Generated example demonstrating the Tag.getfields API.
5 * Demonstrate use of getfields to interrogate api.
10 function tag_getfields_example() {
16 $result = civicrm_api3('Tag', 'getfields', $params);
18 catch (CiviCRM_API3_Exception
$e) {
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
25 'error_message' => $errorMessage,
26 'error_code' => $errorCode,
27 'error_data' => $errorData,
35 * Function returns array of result expected from previous function.
40 function tag_getfields_expectedresult() {
51 'description' => 'Tag ID',
53 'where' => 'civicrm_tag.id',
54 'table_name' => 'civicrm_tag',
56 'bao' => 'CRM_Core_BAO_Tag',
58 'is_core_field' => TRUE,
66 'title' => 'Tag Name',
67 'description' => 'Name of Tag.',
71 'where' => 'civicrm_tag.name',
72 'table_name' => 'civicrm_tag',
74 'bao' => 'CRM_Core_BAO_Tag',
76 'is_core_field' => TRUE,
80 'name' => 'description',
82 'title' => 'Description',
83 'description' => 'Optional verbose description of the tag.',
86 'where' => 'civicrm_tag.description',
87 'table_name' => 'civicrm_tag',
89 'bao' => 'CRM_Core_BAO_Tag',
91 'is_core_field' => TRUE,
94 'name' => 'parent_id',
96 'title' => 'Parent Tag',
97 'description' => 'Optional parent id for this tag.',
98 'where' => 'civicrm_tag.parent_id',
100 'table_name' => 'civicrm_tag',
102 'bao' => 'CRM_Core_BAO_Tag',
104 'FKClassName' => 'CRM_Core_DAO_Tag',
105 'is_core_field' => TRUE,
106 'FKApiName' => 'Tag',
109 'name' => 'is_selectable',
111 'title' => 'Display Tag?',
112 'description' => 'Is this tag selectable / displayed',
113 'where' => 'civicrm_tag.is_selectable',
115 'table_name' => 'civicrm_tag',
117 'bao' => 'CRM_Core_BAO_Tag',
119 'is_core_field' => TRUE,
122 'name' => 'is_reserved',
124 'title' => 'Reserved',
125 'where' => 'civicrm_tag.is_reserved',
126 'table_name' => 'civicrm_tag',
128 'bao' => 'CRM_Core_BAO_Tag',
130 'is_core_field' => TRUE,
133 'name' => 'is_tagset',
136 'where' => 'civicrm_tag.is_tagset',
137 'table_name' => 'civicrm_tag',
139 'bao' => 'CRM_Core_BAO_Tag',
141 'is_core_field' => TRUE,
144 'name' => 'used_for',
146 'title' => 'Used For',
149 'where' => 'civicrm_tag.used_for',
151 'table_name' => 'civicrm_tag',
153 'bao' => 'CRM_Core_BAO_Tag',
161 'pseudoconstant' => [
162 'optionGroupName' => 'tag_used_for',
163 'optionEditPath' => 'civicrm/admin/options/tag_used_for',
165 'is_core_field' => TRUE,
166 'api.default' => 'civicrm_contact',
169 'name' => 'created_id',
171 'title' => 'Tag Created By',
172 'description' => 'FK to civicrm_contact, who created this tag',
173 'where' => 'civicrm_tag.created_id',
174 'table_name' => 'civicrm_tag',
176 'bao' => 'CRM_Core_BAO_Tag',
178 'FKClassName' => 'CRM_Contact_DAO_Contact',
179 'is_core_field' => TRUE,
180 'FKApiName' => 'Contact',
186 'description' => 'Hex color value e.g. #ffffff',
189 'where' => 'civicrm_tag.color',
191 'table_name' => 'civicrm_tag',
193 'bao' => 'CRM_Core_BAO_Tag',
195 'is_core_field' => TRUE,
198 'name' => 'created_date',
200 'title' => 'Tag Created Date',
201 'description' => 'Date and time that tag was created.',
202 'where' => 'civicrm_tag.created_date',
203 'table_name' => 'civicrm_tag',
205 'bao' => 'CRM_Core_BAO_Tag',
207 'is_core_field' => TRUE,
212 return $expectedResult;
216 * This example has been generated from the API test suite.
217 * The test that created it is called "testTagGetfields"
218 * and can be found at:
219 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TagTest.php
221 * You can see the outcome of the API tests at
222 * https://test.civicrm.org/job/CiviCRM-Core-Matrix/
224 * To Learn about the API read
225 * https://docs.civicrm.org/dev/en/latest/api/
227 * Browse the API on your own site with the API Explorer. It is in the main
228 * CiviCRM menu, under: Support > Development > API Explorer.
230 * Read more about testing here
231 * https://docs.civicrm.org/dev/en/latest/testing/
233 * API Standards documentation:
234 * https://docs.civicrm.org/dev/en/latest/framework/api-architecture/