Merge pull request #10155 from totten/master-pdf-save2
[civicrm-core.git] / api / v3 / examples / Event / ContactRefCustomField.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Event.get API.
4 *
5 * Demonstrates get with Contact Reference Custom Field.
6 *
7 * @return array
8 * API result array
9 */
10 function event_get_example() {
11 $params = array(
12 'return.custom_2' => 1,
13 'custom_2' => 4,
14 );
15
16 try{
17 $result = civicrm_api3('Event', 'get', $params);
18 }
19 catch (CiviCRM_API3_Exception $e) {
20 // Handle error here.
21 $errorMessage = $e->getMessage();
22 $errorCode = $e->getErrorCode();
23 $errorData = $e->getExtraParams();
24 return array(
25 'is_error' => 1,
26 'error_message' => $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 event_get_expectedresult() {
42
43 $expectedResult = array(
44 'is_error' => 0,
45 'version' => 3,
46 'count' => 1,
47 'id' => 3,
48 'values' => array(
49 '3' => array(
50 'id' => '3',
51 'title' => 'My test event.',
52 'event_title' => 'My test event.',
53 'event_description' => '',
54 'event_type_id' => '1',
55 'participant_listing_id' => 0,
56 'is_public' => '1',
57 'start_date' => '2013-07-29 00:00:00',
58 'event_start_date' => '2013-07-29 00:00:00',
59 'event_end_date' => '',
60 'is_online_registration' => 0,
61 'is_monetary' => 0,
62 'is_map' => 0,
63 'is_active' => '1',
64 'is_show_location' => '1',
65 'default_role_id' => '1',
66 'is_email_confirm' => 0,
67 'is_pay_later' => 0,
68 'is_partial_payment' => 0,
69 'is_multiple_registrations' => 0,
70 'max_additional_participants' => 0,
71 'allow_same_participant_emails' => 0,
72 'allow_selfcancelxfer' => 0,
73 'selfcancelxfer_time' => 0,
74 'is_template' => 0,
75 'created_date' => '2013-07-28 08:49:19',
76 'is_share' => '1',
77 'is_confirm_enabled' => '1',
78 'is_billing_required' => 0,
79 'custom_1' => 'defaultValue',
80 'custom_2_id' => '4',
81 'custom_2' => 'Contact, Test',
82 ),
83 ),
84 );
85
86 return $expectedResult;
87 }
88
89 /*
90 * This example has been generated from the API test suite.
91 * The test that created it is called "testEventGetCustomContactRefFieldCRM16036"
92 * and can be found at:
93 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/EventTest.php
94 *
95 * You can see the outcome of the API tests at
96 * https://test.civicrm.org/job/CiviCRM-master-git/
97 *
98 * To Learn about the API read
99 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
100 *
101 * Browse the api on your own site with the api explorer
102 * http://MYSITE.ORG/path/to/civicrm/api
103 *
104 * Read more about testing here
105 * http://wiki.civicrm.org/confluence/display/CRM/Testing
106 *
107 * API Standards documentation:
108 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
109 */