Merge remote-tracking branch 'upstream/4.5' into 4.5-master-2015-02-09-11-44-07
[civicrm-core.git] / api / v3 / examples / Tag / Getfields.php
CommitLineData
fb32de45 1<?php
50fb255d 2/**
3 * Test Generated example of using tag getfields API.
4 *
5 * demonstrate use of getfields to interrogate api
6 *
7 * @return array
8 * API result array
9 */
10function tag_getfields_example() {
11 $params = array(
12 'action' => 'create',
13 );
14
15 try{
16 $result = civicrm_api3('tag', 'getfields', $params);
17 }
18 catch (CiviCRM_API3_Exception $e) {
19 // Handle error here.
20 $errorMessage = $e->getMessage();
21 $errorCode = $e->getErrorCode();
22 $errorData = $e->getExtraParams();
23 return array(
24 'error' => $errorMessage,
25 'error_code' => $errorCode,
26 'error_data' => $errorData,
27 );
28 }
fb32de45 29
50fb255d 30 return $result;
fb32de45 31}
32
33/**
50fb255d 34 * Function returns array of result expected from previous function.
35 *
36 * @return array
37 * API result array
fb32de45 38 */
50fb255d 39function tag_getfields_expectedresult() {
fb32de45 40
41 $expectedResult = array(
50fb255d 42 'is_error' => 0,
43 'version' => 3,
44 'count' => 10,
45 'values' => array(
fb32de45 46 'id' => array(
50fb255d 47 'name' => 'id',
48 'type' => 1,
49 'title' => 'Tag ID',
50 'required' => TRUE,
51 'api.aliases' => array(
52 '0' => 'tag',
fb32de45 53 ),
50fb255d 54 ),
fb32de45 55 'name' => array(
50fb255d 56 'name' => 'name',
57 'type' => 2,
58 'title' => 'Tag Name',
59 'required' => TRUE,
60 'maxlength' => 64,
61 'size' => 30,
62 'api.required' => 1,
63 ),
fb32de45 64 'description' => array(
50fb255d 65 'name' => 'description',
66 'type' => 2,
67 'title' => 'Description',
68 'maxlength' => 255,
69 'size' => 45,
70 ),
fb32de45 71 'parent_id' => array(
50fb255d 72 'name' => 'parent_id',
73 'type' => 1,
74 'title' => 'Parent Tag',
75 'default' => 'NULL',
76 'FKClassName' => 'CRM_Core_DAO_Tag',
77 'FKApiName' => 'Tag',
78 ),
fb32de45 79 'is_selectable' => array(
50fb255d 80 'name' => 'is_selectable',
81 'type' => 16,
82 'title' => 'Display Tag?',
83 'default' => '1',
84 ),
fb32de45 85 'is_reserved' => array(
50fb255d 86 'name' => 'is_reserved',
87 'type' => 16,
88 'title' => 'Reserved',
89 ),
fb32de45 90 'is_tagset' => array(
50fb255d 91 'name' => 'is_tagset',
92 'type' => 16,
93 'title' => 'Tagset',
94 ),
fb32de45 95 'used_for' => array(
50fb255d 96 'name' => 'used_for',
97 'type' => 2,
98 'title' => 'Used For',
99 'maxlength' => 64,
100 'size' => 30,
101 'default' => 'NULL',
102 'html' => array(
103 'type' => 'Select',
fb32de45 104 ),
50fb255d 105 'pseudoconstant' => array(
106 'optionGroupName' => 'tag_used_for',
fb32de45 107 ),
50fb255d 108 'api.default' => 'civicrm_contact',
109 ),
110 'created_id' => array(
111 'name' => 'created_id',
112 'type' => 1,
113 'title' => 'Tag Created By',
114 'FKClassName' => 'CRM_Contact_DAO_Contact',
115 'FKApiName' => 'Contact',
116 ),
fb32de45 117 'created_date' => array(
50fb255d 118 'name' => 'created_date',
119 'type' => 12,
120 'title' => 'Tag Created Date',
121 ),
fb32de45 122 ),
50fb255d 123 );
fb32de45 124
125 return $expectedResult;
126}
127
50fb255d 128/**
129* This example has been generated from the API test suite.
130* The test that created it is called
131* testTagGetfields
132* and can be found in
69d79249 133* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/TagTest.php
fb32de45 134*
135* You can see the outcome of the API tests at
69d79249 136* https://test.civicrm.org/job/CiviCRM-master-git/
fb32de45 137*
138* To Learn about the API read
69d79249 139* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
fb32de45 140*
69d79249 141* Browse the api on your own site with the api explorer
41d4d31f 142* http://MYSITE.ORG/path/to/civicrm/api
fb32de45 143*
144* Read more about testing here
145* http://wiki.civicrm.org/confluence/display/CRM/Testing
146*
147* API Standards documentation:
148* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
b259a4ab 149*/