Merge branch 4.5 into master
[civicrm-core.git] / api / v3 / examples / Setting / GetDefaults.php
index 4b5efa7526f105c08e6676e5d0f15c48638b85bf..75c11cf9eaeec67441ac7f0b01068f0218636c7d 100644 (file)
@@ -1,20 +1,28 @@
 <?php
-
-/*
- gets defaults setting a variable for a given domain - if no domain is set current is assumed
+/**
+ * Test Generated example of using setting getdefaults API
+ * gets defaults setting a variable for a given domain - if no domain is set current is assumed *
  */
 function setting_getdefaults_example(){
 $params = array(
-  'version' => 3,
   'name' => 'address_format',
 );
 
-  $result = civicrm_api( 'setting','getdefaults',$params );
+try{
+  $result = civicrm_api3('setting', 'getdefaults', $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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_getdefaults_expectedresult(){
@@ -36,7 +44,7 @@ function setting_getdefaults_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -44,20 +52,20 @@ function setting_getdefaults_expectedresult(){
 * This example has been generated from the API test suite. The test that created it is called
 *
 * testGetDefaults and can be found in
-* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/SettingTest.php
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/SettingTest.php
 *
 * You can see the outcome of the API tests at
-* http://tests.dev.civicrm.org/trunk/results-api_v3
+* https://test.civicrm.org/job/CiviCRM-master-git/
 *
 * To Learn about the API read
-* http://book.civicrm.org/developer/current/techniques/api/
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
 *
-* and review the wiki at
-* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api/explorer
 *
 * Read more about testing here
 * http://wiki.civicrm.org/confluence/display/CRM/Testing
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/