Merge pull request #9616 from ErichBSchulz/feature/drupal_boot_no_exit
[civicrm-core.git] / api / v3 / examples / ActivityType / Create.php
1 <?php
2 /**
3 * Test Generated example demonstrating the ActivityType.create API.
4 *
5 * @deprecated
6 * The ActivityType api is deprecated. Please use the OptionValue api instead.
7 *
8 * @return array
9 * API result array
10 */
11 function activity_type_create_example() {
12 $params = array(
13 'weight' => '2',
14 'label' => 'send out letters',
15 'filter' => 0,
16 'is_active' => 1,
17 'is_optgroup' => 1,
18 'is_default' => 0,
19 );
20
21 try{
22 $result = civicrm_api3('ActivityType', 'create', $params);
23 }
24 catch (CiviCRM_API3_Exception $e) {
25 // Handle error here.
26 $errorMessage = $e->getMessage();
27 $errorCode = $e->getErrorCode();
28 $errorData = $e->getExtraParams();
29 return array(
30 'is_error' => 1,
31 'error_message' => $errorMessage,
32 'error_code' => $errorCode,
33 'error_data' => $errorData,
34 );
35 }
36
37 return $result;
38 }
39
40 /**
41 * Function returns array of result expected from previous function.
42 *
43 * @return array
44 * API result array
45 */
46 function activity_type_create_expectedresult() {
47
48 $expectedResult = array(
49 'is_error' => 0,
50 'version' => 3,
51 'count' => 1,
52 'id' => 849,
53 'values' => array(
54 '849' => array(
55 'id' => '849',
56 'option_group_id' => '2',
57 'label' => 'send out letters',
58 'value' => '55',
59 'name' => 'send out letters',
60 'grouping' => '',
61 'filter' => 0,
62 'is_default' => 0,
63 'weight' => '2',
64 'description' => '',
65 'is_optgroup' => '1',
66 'is_reserved' => '',
67 'is_active' => '1',
68 'component_id' => '',
69 'domain_id' => '',
70 'visibility_id' => '',
71 'icon' => '',
72 'color' => '',
73 ),
74 ),
75 'deprecated' => 'The ActivityType api is deprecated. Please use the OptionValue api instead.',
76 );
77
78 return $expectedResult;
79 }
80
81 /*
82 * This example has been generated from the API test suite.
83 * The test that created it is called "testActivityTypeCreate"
84 * and can be found at:
85 * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/ActivityTypeTest.php
86 *
87 * You can see the outcome of the API tests at
88 * https://test.civicrm.org/job/CiviCRM-master-git/
89 *
90 * To Learn about the API read
91 * http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
92 *
93 * Browse the api on your own site with the api explorer
94 * http://MYSITE.ORG/path/to/civicrm/api
95 *
96 * Read more about testing here
97 * http://wiki.civicrm.org/confluence/display/CRM/Testing
98 *
99 * API Standards documentation:
100 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
101 */