Short array syntax - auto-convert api dir
[civicrm-core.git] / api / v3 / examples / Relationship / filterIsCurrent.php
1 <?php
2 /**
3 * Test Generated example demonstrating the Relationship.get API.
4 *
5 * Demonstrates is_current filter.
6 *
7 * @return array
8 * API result array
9 */
10 function relationship_get_example() {
11 $params = [
12 'filters' => [
13 'is_current' => 1,
14 ],
15 ];
16
17 try{
18 $result = civicrm_api3('Relationship', '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 [
26 'is_error' => 1,
27 'error_message' => $errorMessage,
28 'error_code' => $errorCode,
29 'error_data' => $errorData,
30 ];
31 }
32
33 return $result;
34 }
35
36 /**
37 * Function returns array of result expected from previous function.
38 *
39 * @return array
40 * API result array
41 */
42 function relationship_get_expectedresult() {
43
44 $expectedResult = [
45 'is_error' => 0,
46 'version' => 3,
47 'count' => 1,
48 'id' => 2,
49 'values' => [
50 '2' => [
51 'id' => '2',
52 'contact_id_a' => '95',
53 'contact_id_b' => '97',
54 'relationship_type_id' => '34',
55 'start_date' => '2013-07-29 00:00:00',
56 'is_active' => '1',
57 'is_permission_a_b' => 0,
58 'is_permission_b_a' => 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 "testGetIsCurrent"
69 * and can be found at:
70 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/RelationshipTest.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 */