Merge pull request #9864 from PalanteJon/CRM-19977
[civicrm-core.git] / api / v3 / examples / Contact / GetActions.php
CommitLineData
92776611 1<?php
50fb255d 2/**
a828d7b8 3 * Test Generated example demonstrating the Contact.getactions API.
50fb255d 4 *
5 * Getting the available actions for an entity.
6 *
7 * @return array
8 * API result array
9 */
10function contact_getactions_example() {
11 $params = array();
92776611 12
50fb255d 13 try{
a828d7b8 14 $result = civicrm_api3('Contact', 'getactions', $params);
50fb255d 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(
5be22f39 22 'is_error' => 1,
23 'error_message' => $errorMessage,
50fb255d 24 'error_code' => $errorCode,
25 'error_data' => $errorData,
26 );
27 }
28
29 return $result;
92776611
CW
30}
31
32/**
50fb255d 33 * Function returns array of result expected from previous function.
34 *
35 * @return array
36 * API result array
92776611 37 */
50fb255d 38function contact_getactions_expectedresult() {
92776611
CW
39
40 $expectedResult = array(
50fb255d 41 'is_error' => 0,
42 'version' => 3,
d0aa0e47 43 'count' => 20,
50fb255d 44 'values' => array(
92776611
CW
45 '0' => 'create',
46 '1' => 'delete',
5be22f39 47 '2' => 'duplicatecheck',
d0aa0e47
SL
48 '3' => 'get',
49 '4' => 'getactions',
50 '5' => 'getcount',
51 '6' => 'getfield',
52 '7' => 'getfields',
53 '8' => 'getlist',
54 '9' => 'getoptions',
55 '10' => 'getquick',
56 '11' => 'getrefcount',
57 '12' => 'getsingle',
58 '13' => 'getvalue',
59 '14' => 'merge',
60 '15' => 'proximity',
61 '16' => 'replace',
62 '17' => 'setvalue',
63 '18' => 'update',
64 '19' => 'validate',
92776611 65 ),
50fb255d 66 'deprecated' => array(
92776611 67 'getquick' => 'The "getquick" action is deprecated in favor of "getlist".',
265df5a0 68 'setvalue' => 'The "setvalue" action is deprecated. Use "create" with an id instead.',
92776611
CW
69 'update' => 'The "update" action is deprecated. Use "create" with an id instead.',
70 ),
50fb255d 71 );
92776611
CW
72
73 return $expectedResult;
74}
75
a828d7b8 76/*
50fb255d 77* This example has been generated from the API test suite.
a828d7b8
CW
78* The test that created it is called "testGetActions"
79* and can be found at:
92776611
CW
80* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ContactTest.php
81*
82* You can see the outcome of the API tests at
83* https://test.civicrm.org/job/CiviCRM-master-git/
84*
85* To Learn about the API read
86* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
87*
88* Browse the api on your own site with the api explorer
41d4d31f 89* http://MYSITE.ORG/path/to/civicrm/api
92776611
CW
90*
91* Read more about testing here
92* http://wiki.civicrm.org/confluence/display/CRM/Testing
93*
94* API Standards documentation:
95* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
96*/