Additional Test, fix typos (mis-cased class-names), commit updated test-generated...
[civicrm-core.git] / api / v3 / examples / Setting / CreateSettingCurrentDomain.php
index e236b2a38184ee3fe0056dd708c751f38fe169b0..95c6a3e748a9e0cfd64e6d647fb51e05c28d8658 100644 (file)
@@ -1,37 +1,45 @@
 <?php
-
-/*
- shows setting a variable for a current domain
+/**
+ * Test Generated example of using setting create API
+ * shows setting a variable for a current domain *
  */
 function setting_create_example(){
-$params = array( 
-  'version' => 3,
+$params = array(
   'uniq_email_per_site' => 1,
 );
 
-  $result = civicrm_api( 'setting','create',$params );
+try{
+  $result = civicrm_api3('setting', '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;
+return $result;
 }
 
-/*
+/**
  * Function returns array of result expected from previous function
  */
 function setting_create_expectedresult(){
 
-  $expectedResult = array( 
+  $expectedResult = array(
   'is_error' => 0,
   'version' => 3,
   'count' => 1,
   'id' => 1,
-  'values' => array( 
-      '1' => array( 
+  'values' => array(
+      '1' => array(
           'uniq_email_per_site' => '1',
         ),
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }
 
 
@@ -55,4 +63,4 @@ function setting_create_expectedresult(){
 *
 * API Standards documentation:
 * http://wiki.civicrm.org/confluence/display/CRM/API+Architecture+Standards
-*/
\ No newline at end of file
+*/