Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / CustomGroup / Get.php
CommitLineData
6a488035 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the CustomGroup.get API.
50fb255d 4 *
50fb255d 5 * @return array
6 * API result array
7 */
8function custom_group_get_example() {
cf8f0fff 9 $params = [];
6a488035 10
50fb255d 11 try{
a828d7b8 12 $result = civicrm_api3('CustomGroup', 'get', $params);
50fb255d 13 }
14 catch (CiviCRM_API3_Exception $e) {
15 // Handle error here.
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
cf8f0fff 19 return [
5be22f39 20 'is_error' => 1,
21 'error_message' => $errorMessage,
50fb255d 22 'error_code' => $errorCode,
23 'error_data' => $errorData,
cf8f0fff 24 ];
50fb255d 25 }
26
27 return $result;
6a488035
TO
28}
29
fb32de45 30/**
50fb255d 31 * Function returns array of result expected from previous function.
32 *
33 * @return array
34 * API result array
6a488035 35 */
50fb255d 36function custom_group_get_expectedresult() {
6a488035 37
cf8f0fff 38 $expectedResult = [
50fb255d 39 'is_error' => 0,
40 'version' => 3,
41 'count' => 1,
42 'id' => 1,
cf8f0fff
CW
43 'values' => [
44 '1' => [
50fb255d 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,
cf8f0fff
CW
59 ],
60 ],
61 ];
6a488035 62
fb32de45 63 return $expectedResult;
6a488035
TO
64}
65
a828d7b8 66/*
50fb255d 67* This example has been generated from the API test suite.
a828d7b8
CW
68* The test that created it is called "testGetCustomGroupSuccess"
69* and can be found at:
69d79249 70* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomGroupTest.php
6a488035
TO
71*
72* You can see the outcome of the API tests at
69d79249 73* https://test.civicrm.org/job/CiviCRM-master-git/
6a488035
TO
74*
75* To Learn about the API read
69d79249 76* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
6a488035 77*
69d79249 78* Browse the api on your own site with the api explorer
41d4d31f 79* http://MYSITE.ORG/path/to/civicrm/api
6a488035
TO
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
b259a4ab 86*/