Merge pull request #9670 from johanv/CRM-19869-pdf_table_header_issue
[civicrm-core.git] / api / v3 / examples / CustomValue / FormatFieldName.php
1 <?php
2 /**
3 * Test Generated example demonstrating the CustomValue.get API.
4 *
5 * utilises field names
6 *
7 * @return array
8 * API result array
9 */
10 function custom_value_get_example() {
11 $params = array(
12 'id' => 2,
13 'entity_id' => 2,
14 'format.field_names' => 1,
15 );
16
17 try{
18 $result = civicrm_api3('CustomValue', 'get', $params);
19 }
20 catch (CiviCRM_API3_Exception $e) {
21 // Handle error here.
22 $errorMessage = $e->getMessage();
23 $errorCode = $e->getErrorCode();
24 $errorData = $e->getExtraParams();
25 return array(
26 'error' => $errorMessage,
27 'error_code' => $errorCode,
28 'error_data' => $errorData,
29 );
30 }
31
32 return $result;
33 }
34
35 /**
36 * Function returns array of result expected from previous function.
37 *
38 * @return array
39 * API result array
40 */
41 function custom_value_get_expectedresult() {
42
43 $expectedResult = array(
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 7,
47 'values' => array(
48 'mySingleField' => array(
49 'entity_id' => '2',
50 'latest' => 'value 1',
51 'id' => 'mySingleField',
52 ),
53 'field_12' => array(
54 'entity_id' => '2',
55 'latest' => 'value 3',
56 'id' => 'field_12',
57 '1' => 'value 2',
58 '2' => 'value 3',
59 ),
60 'field_22' => array(
61 'entity_id' => '2',
62 'latest' => '',
63 'id' => 'field_22',
64 '1' => 'warm beer',
65 '2' => '',
66 ),
67 'field_32' => array(
68 'entity_id' => '2',
69 'latest' => '',
70 'id' => 'field_32',
71 '1' => 'fl* w*',
72 '2' => '',
73 ),
74 'field_13' => array(
75 'entity_id' => '2',
76 'latest' => 'coffee',
77 'id' => 'field_13',
78 '1' => 'defaultValue',
79 '2' => 'coffee',
80 ),
81 'field_23' => array(
82 'entity_id' => '2',
83 'latest' => 'value 4',
84 'id' => 'field_23',
85 '1' => '',
86 '2' => 'value 4',
87 ),
88 'field_33' => array(
89 'entity_id' => '2',
90 'latest' => '',
91 'id' => 'field_33',
92 '1' => 'vegemite',
93 '2' => '',
94 ),
95 ),
96 );
97
98 return $expectedResult;
99 }
100
101 /*
102 * This example has been generated from the API test suite.
103 * The test that created it is called "testGetMultipleCustomValues"
104 * and can be found at:
105 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/CustomValueTest.php
106 *
107 * You can see the outcome of the API tests at
108 * https://test.civicrm.org/job/CiviCRM-master-git/
109 *
110 * To Learn about the API read
111 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
112 *
113 * Browse the api on your own site with the api explorer
114 * http://MYSITE.ORG/path/to/civicrm/api
115 *
116 * Read more about testing here
117 * http://wiki.civicrm.org/confluence/display/CRM/Testing
118 *
119 * API Standards documentation:
120 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
121 */