Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / CustomGroup / Get.php
1 <?php
2 /**
3 * Test Generated example demonstrating the CustomGroup.get API.
4 *
5 * @return array
6 * API result array
7 */
8 function custom_group_get_example() {
9 $params = [];
10
11 try{
12 $result = civicrm_api3('CustomGroup', 'get', $params);
13 }
14 catch (CiviCRM_API3_Exception $e) {
15 // Handle error here.
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return [
20 'is_error' => 1,
21 'error_message' => $errorMessage,
22 'error_code' => $errorCode,
23 'error_data' => $errorData,
24 ];
25 }
26
27 return $result;
28 }
29
30 /**
31 * Function returns array of result expected from previous function.
32 *
33 * @return array
34 * API result array
35 */
36 function custom_group_get_expectedresult() {
37
38 $expectedResult = [
39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 1,
43 'values' => [
44 '1' => [
45 'id' => '1',
46 'name' => 'test_group_1',
47 'title' => 'Test_Group_1',
48 'extends' => 'Individual',
49 'style' => 'Inline',
50 'collapse_display' => '1',
51 'help_pre' => 'This is Pre Help For Test Group 1',
52 'help_post' => 'This is Post Help For Test Group 1',
53 'weight' => '2',
54 'is_active' => '1',
55 'table_name' => 'civicrm_value_test_group_1_1',
56 'is_multiple' => 0,
57 'collapse_adv_display' => 0,
58 'is_reserved' => 0,
59 ],
60 ],
61 ];
62
63 return $expectedResult;
64 }
65
66 /*
67 * This example has been generated from the API test suite.
68 * The test that created it is called "testGetCustomGroupSuccess"
69 * and can be found at:
70 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomGroupTest.php
71 *
72 * You can see the outcome of the API tests at
73 * https://test.civicrm.org/job/CiviCRM-master-git/
74 *
75 * To Learn about the API read
76 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
77 *
78 * Browse the api on your own site with the api explorer
79 * http://MYSITE.ORG/path/to/civicrm/api
80 *
81 * Read more about testing here
82 * http://wiki.civicrm.org/confluence/display/CRM/Testing
83 *
84 * API Standards documentation:
85 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
86 */