X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=api%2Fv3%2Fexamples%2FUFField%2FCreate.php;h=4574229cfeeed0573a573d02b4525ee547bf9b00;hb=82e7a8b8a4054c4814900ddf5e8fc56d6819c134;hp=701f005699b1f7f5136dd14830a0c7161b382f99;hpb=5b98b56e80d856d22291fe217a052d90593a77b1;p=civicrm-core.git diff --git a/api/v3/examples/UFField/Create.php b/api/v3/examples/UFField/Create.php index 701f005699..4574229cfe 100644 --- a/api/v3/examples/UFField/Create.php +++ b/api/v3/examples/UFField/Create.php @@ -1,79 +1,95 @@ 'phone', - 'field_type' => 'Contact', - 'visibility' => 'Public Pages and Listings', - 'weight' => 1, - 'label' => 'Test Phone', - 'is_searchable' => 1, - 'is_active' => 1, - 'location_type_id' => 1, - 'phone_type_id' => 1, - 'uf_group_id' => 11, -); -try{ - $result = civicrm_api3('uf_field', 'create', $params); -} -catch (CiviCRM_API3_Exception $e) { - // handle error here - $errorMessage = $e->getMessage(); - $errorCode = $e->getErrorCode(); - $errorData = $e->getExtraParams(); - return array('error' => $errorMessage, 'error_code' => $errorCode, 'error_data' => $errorData); -} +/** + * Test Generated example of using uf_field create API. + * + * + * @return array + * API result array + */ +function uf_field_create_example() { + $params = array( + 'field_name' => 'phone', + 'field_type' => 'Contact', + 'visibility' => 'Public Pages and Listings', + 'weight' => 1, + 'label' => 'Test Phone', + 'is_searchable' => 1, + 'is_active' => 1, + 'location_type_id' => 1, + 'phone_type_id' => 1, + 'uf_group_id' => 11, + ); -return $result; + try{ + $result = civicrm_api3('uf_field', 'create', $params); + } + catch (CiviCRM_API3_Exception $e) { + // Handle error here. + $errorMessage = $e->getMessage(); + $errorCode = $e->getErrorCode(); + $errorData = $e->getExtraParams(); + return array( + 'error' => $errorMessage, + 'error_code' => $errorCode, + 'error_data' => $errorData, + ); + } + + return $result; } /** - * Function returns array of result expected from previous function + * Function returns array of result expected from previous function. + * + * @return array + * API result array */ -function uf_field_create_expectedresult(){ +function uf_field_create_expectedresult() { $expectedResult = array( - 'is_error' => 0, - 'version' => 3, - 'count' => 1, - 'id' => 1, - 'values' => array( + 'is_error' => 0, + 'version' => 3, + 'count' => 1, + 'id' => 1, + 'values' => array( '1' => array( - 'id' => '1', - 'uf_group_id' => '11', - 'field_name' => 'phone', - 'is_active' => '1', - 'is_view' => '', - 'is_required' => '', - 'weight' => '1', - 'help_post' => '', - 'help_pre' => '', - 'visibility' => 'Public Pages and Listings', - 'in_selector' => '', - 'is_searchable' => '1', - 'location_type_id' => '1', - 'phone_type_id' => '1', - 'website_type_id' => '', - 'label' => 'Test Phone', - 'field_type' => 'Contact', - 'is_reserved' => '', - 'is_multi_summary' => '', - ), + 'id' => '1', + 'uf_group_id' => '11', + 'field_name' => 'phone', + 'is_active' => '1', + 'is_view' => '', + 'is_required' => '', + 'weight' => '1', + 'help_post' => '', + 'help_pre' => '', + 'visibility' => 'Public Pages and Listings', + 'in_selector' => '', + 'is_searchable' => '1', + 'location_type_id' => '1', + 'phone_type_id' => '1', + 'website_type_id' => '', + 'label' => 'Test Phone', + 'field_type' => 'Contact', + 'is_reserved' => '', + 'is_multi_summary' => '', + ), ), -); + ); return $expectedResult; } - -/* -* This example has been generated from the API test suite. The test that created it is called -* -* testCreateUFField and can be found in +/** +* This example has been generated from the API test suite. +* The test that created it is called +* testCreateUFField +* and can be found in * https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/UFFieldTest.php * * You can see the outcome of the API tests at