Merge remote-tracking branch 'upstream/4.3' into 4.3-4.4-2013-10-21-22-31-28
[civicrm-core.git] / api / v3 / examples / Setting / CreateSettingCurrentDomain.php
index d41cd0383cdb279ccff7698882f94c4edc7eb671..78d29eeb58966b8e8a29b45dba36215d4891b86f 100644 (file)
@@ -1,20 +1,28 @@
 <?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,
   '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(){
@@ -31,7 +39,7 @@ function setting_create_expectedresult(){
     ),
 );
 
-  return $expectedResult  ;
+  return $expectedResult;
 }