Merge pull request #2749 from monishdeb/HR-317
[civicrm-core.git] / api / v3 / examples / Website / GetFields.php
CommitLineData
dc5a7701
E
1<?php
2/**
3 * Test Generated example of using website getfields API
4 * *
5 */
6function website_getfields_example(){
7$params = array(
8 'action' => 'get',
9);
10
11try{
12 $result = civicrm_api3('website', 'getfields', $params);
13}
14catch (CiviCRM_API3_Exception $e) {
15 // handle error here
16 $errorMessage = $e->getMessage();
17 $errorCode = $e->getErrorCode();
18 $errorData = $e->getExtraParams();
19 return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData);
20}
21
22return $result;
23}
24
25/**
26 * Function returns array of result expected from previous function
27 */
28function website_getfields_expectedresult(){
29
30 $expectedResult = array(
31 'is_error' => 0,
32 'version' => 3,
33 'count' => 4,
34 'values' => array(
35 'id' => array(
36 'name' => 'id',
37 'type' => 1,
38 'title' => 'Website ID',
39 'required' => true,
40 'api.aliases' => array(
41 '0' => 'website_id',
42 ),
43 ),
44 'contact_id' => array(
45 'name' => 'contact_id',
46 'type' => 1,
47 'title' => 'Contact',
48 'FKClassName' => 'CRM_Contact_DAO_Contact',
49 ),
50 'url' => array(
51 'name' => 'url',
52 'type' => 2,
53 'title' => 'Website',
54 'maxlength' => 128,
55 'size' => 30,
56 'import' => true,
57 'where' => 'civicrm_website.url',
58 'headerPattern' => '/Website/i',
59 'dataPattern' => '/^[A-Za-z][0-9A-Za-z]{20,}$/',
60 'export' => true,
61 ),
62 'website_type_id' => array(
63 'name' => 'website_type_id',
64 'type' => 1,
65 'title' => 'Website Type',
66 'pseudoconstant' => array(
67 'optionGroupName' => 'website_type',
68 ),
69 ),
70 ),
71);
72
73 return $expectedResult;
74}
75
76
77/*
78* This example has been generated from the API test suite. The test that created it is called
79*
80* testGetFields and can be found in
69d79249 81* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/WebsiteTest.php
dc5a7701
E
82*
83* You can see the outcome of the API tests at
69d79249 84* https://test.civicrm.org/job/CiviCRM-master-git/
dc5a7701
E
85*
86* To Learn about the API read
69d79249 87* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
dc5a7701 88*
69d79249
E
89* Browse the api on your own site with the api explorer
90* http://MYSITE.ORG/path/to/civicrm/api/explorer
dc5a7701
E
91*
92* Read more about testing here
93* http://wiki.civicrm.org/confluence/display/CRM/Testing
94*
95* API Standards documentation:
96* http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
97*/