Merge pull request #1274 from davecivicrm/CRM-13117
[civicrm-core.git] / api / v3 / examples / CustomValue / formatFieldName.php
1 <?php
2 /**
3 * Test Generated example of using custom_value get API
4 * utilises field names *
5 */
6 function custom_value_get_example(){
7 $params = array(
8 'id' => 2,
9 'entity_id' => 2,
10 'format.field_names' => 1,
11 );
12
13 try{
14 $result = civicrm_api3('custom_value', 'get', $params);
15 }
16 catch (CiviCRM_API3_Exception $e) {
17 // handle error here
18 $errorMessage = $e->getMessage();
19 $errorCode = $e->getErrorCode();
20 $errorData = $e->getExtraParams();
21 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
22 }
23
24 return $result;
25 }
26
27 /**
28 * Function returns array of result expected from previous function
29 */
30 function custom_value_get_expectedresult(){
31
32 $expectedResult = array(
33 'is_error' => 0,
34 'version' => 3,
35 'count' => 4,
36 'values' => array(
37 'mySingleField' => array(
38 'entity_id' => '2',
39 'latest' => 'value 1',
40 'id' => 'mySingleField',
41 ),
42 'Cust_Field' => array(
43 'entity_id' => '2',
44 'latest' => 'coffee',
45 'id' => 'Cust_Field',
46 '1' => '',
47 '2' => 'coffee',
48 ),
49 'field_2' => array(
50 'entity_id' => '2',
51 'latest' => 'value 4',
52 'id' => 'field_2',
53 '1' => '',
54 '2' => 'value 4',
55 ),
56 'field_3' => array(
57 'entity_id' => '2',
58 'latest' => '',
59 'id' => 'field_3',
60 '1' => 'vegemite',
61 '2' => '',
62 ),
63 ),
64 );
65
66 return $expectedResult;
67 }
68
69
70 /*
71 * This example has been generated from the API test suite. The test that created it is called
72 *
73 * testGetMultipleCustomValues and can be found in
74 * http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/CustomValueTest.php
75 *
76 * You can see the outcome of the API tests at
77 * http://tests.dev.civicrm.org/trunk/results-api_v3
78 *
79 * To Learn about the API read
80 * http://book.civicrm.org/developer/current/techniques/api/
81 *
82 * and review the wiki at
83 * http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
84 *
85 * Read more about testing here
86 * http://wiki.civicrm.org/confluence/display/CRM/Testing
87 *
88 * API Standards documentation:
89 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
90 */