INFRA-132 - Batch 14 (g)
[civicrm-core.git] / api / v3 / Setting.php
index 0b107b7b6110844d5c44ad9ab259318100d71694..797cb8537d720696a33ba7774659be4262dc7b4a 100644 (file)
@@ -32,7 +32,8 @@
  * @subpackage API_Settings
  * @copyright CiviCRM LLC (c) 2004-2014
  * @version $Id: Settings.php
- *
+ * @param array $params
+ * @return array
  */
 
 function civicrm_api3_setting_getfields($params) {
@@ -46,7 +47,7 @@ function civicrm_api3_setting_getfields($params) {
         'api.required' => 0,
         'title' => 'Setting Group',
         'description' => 'Settings Group. This is required if the setting is not stored in config',
-        'type' => CRM_Utils_Type::T_STRING)
+        'type' => CRM_Utils_Type::T_STRING),
       );
     return civicrm_api3_create_success($result, $params, 'setting', 'getfields');
   }
@@ -73,6 +74,7 @@ function civicrm_api3_setting_getfields($params) {
 
 /**
  * Alter metadata for getfields functions
+ * @param array $params
  */
 function _civicrm_api3_setting_getfields_spec(&$params) {
   $params['filters'] = array('title' => 'Fields you wish to filter by e.g. array("group_name" => "CiviCRM Preferences")');
@@ -84,6 +86,10 @@ function _civicrm_api3_setting_getfields_spec(&$params) {
  * Return default values for settings. We will domain key this as it could vary by domain (ie. urls)
  * as we will be creating the option for a function rather than an value to be in the defaults
  * Note that is not in place as yet
+ * @param array $params
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ * @throws \Exception
  */
 function civicrm_api3_setting_getdefaults(&$params) {
   $settings = civicrm_api3('setting', 'getfields', $params);
@@ -96,7 +102,7 @@ function civicrm_api3_setting_getdefaults(&$params) {
       if (array_key_exists('default', $spec) && !is_null($spec['default'])) {
         $defaults[$domainID][$setting] = $spec['default'];
       }
-      else{
+      else {
         $noDefaults[$setting] = 1;
       }
     }
@@ -124,6 +130,9 @@ function _civicrm_api3_setting_getdefaults_spec(&$params) {
 
 /**
  * Revert settings to defaults
+ * @param array $params
+ * @return array
+ * @throws \Exception
  */
 function civicrm_api3_setting_revert(&$params) {
   $defaults = civicrm_api('setting', 'getdefaults', $params);
@@ -146,6 +155,7 @@ function civicrm_api3_setting_revert(&$params) {
 
 /**
  * Alter metadata for getfields functions
+ * @param array $params
  */
 function _civicrm_api3_setting_revert_spec(&$params) {
   $params['name'] = array('title' => 'Setting Name belongs to');
@@ -160,6 +170,10 @@ function _civicrm_api3_setting_revert_spec(&$params) {
 
 /**
  * Revert settings to defaults
+ * @param array $params
+ * @return array
+ * @throws \CiviCRM_API3_Exception
+ * @throws \Exception
  */
 function civicrm_api3_setting_fill(&$params) {
   $defaults = civicrm_api3('setting', 'getdefaults', $params);
@@ -168,7 +182,7 @@ function civicrm_api3_setting_fill(&$params) {
   foreach ($domains as $domainID) {
     $apiArray = array(
       'version' => $params['version'],
-      'domain_id' => $domainID
+      'domain_id' => $domainID,
     );
     $existing = civicrm_api3('setting', 'get', $apiArray);
     $valuesToFill = array_diff_key($defaults['values'][$domainID], $existing['values'][$domainID]);
@@ -181,6 +195,7 @@ function civicrm_api3_setting_fill(&$params) {
 
 /**
  * Alter metadata for getfields functions
+ * @param array $params
  */
 function _civicrm_api3_setting_fill_spec(&$params) {
   $params['name'] = array('title' => 'Setting Name belongs to');
@@ -189,7 +204,7 @@ function _civicrm_api3_setting_fill_spec(&$params) {
     'api.default' => 'current_domain',
     'title' => 'Setting Domain',
     'description' => 'Defaults may differ by domain - if you do not pass in a domain id this will default to the current domain
-      an array or "all" are acceptable values for multiple domains'
+      an array or "all" are acceptable values for multiple domains',
   );
 }
 
@@ -201,9 +216,9 @@ function _civicrm_api3_setting_fill_spec(&$params) {
  *                       name/value pairs + other vars as applicable - see getfields for more
  * @example SettingCreate.php Std Create example
  *
- * @return array api result array
+ * @return array
+ *   api result array
  * {@getfields setting_create}
- * @access public
  */
 function civicrm_api3_setting_create($params) {
   $domains = _civicrm_api3_setting_getDomainArray($params);
@@ -222,11 +237,11 @@ function _civicrm_api3_setting_create_spec(&$params) {
     'api.default' => 'current_domain',
     'title' => 'Setting Domain',
     'description' => 'if you do not pass in a domain id this will default to the current domain
-      an array or "all" are acceptable values for multiple domains'
+      an array or "all" are acceptable values for multiple domains',
    );
   $params['group'] = array(
      'title' => 'Setting Group',
-     'description' => 'if you know the group defining it will make the api more efficient'
+     'description' => 'if you know the group defining it will make the api more efficient',
    );
 }
 
@@ -237,9 +252,9 @@ function _civicrm_api3_setting_create_spec(&$params) {
  *   Array of one or more valid.
  *                       property_name=>value pairs.
  *
- * @return array Array of matching settings
+ * @return array
+ *   Array of matching settings
  * {@getfields setting_get}
- * @access public
  */
 function civicrm_api3_setting_get($params) {
   $domains = _civicrm_api3_setting_getDomainArray($params);
@@ -256,11 +271,11 @@ function _civicrm_api3_setting_get_spec(&$params) {
   $params['domain_id'] = array(
     'api.default' => 'current_domain',
     'title' => 'Setting Domain',
-    'description' => 'if you do not pass in a domain id this will default to the current domain'
+    'description' => 'if you do not pass in a domain id this will default to the current domain',
   );
   $params['group'] = array(
     'title' => 'Setting Group',
-    'description' => 'if you know the group defining it will make the api more efficient'
+    'description' => 'if you know the group defining it will make the api more efficient',
   );
 }
 /**
@@ -271,9 +286,9 @@ function _civicrm_api3_setting_get_spec(&$params) {
  *   (reference) Array of one or more valid.
  *                       property_name=>value pairs.
  *
- * @return array Array of matching settings
+ * @return array
+ *   Array of matching settings
  * {@getfields setting_get}
- * @access public
  */
 function civicrm_api3_setting_getvalue($params) {
   $config = CRM_Core_Config::singleton();
@@ -317,7 +332,7 @@ function _civicrm_api3_setting_getvalue_spec(&$params) {
   );
   $params['domain_id'] = array(
     'title' => 'Setting Domain',
-    'description' => 'if you do not pass in a domain id this will default to the current domain'
+    'description' => 'if you do not pass in a domain id this will default to the current domain',
   );
 }
 
@@ -328,6 +343,9 @@ function _civicrm_api3_setting_getvalue_spec(&$params) {
  * Really domain_id should always be set but doing an empty check because at the moment
  * using crm-editable will pass an id & default won't be applied
  * we did talk about id being a pseudonym for domain_id in this api so applying it here
+ * @param array $params
+ * @return array
+ * @throws \Exception
  */
 function _civicrm_api3_setting_getDomainArray(&$params) {
   if (empty($params['domain_id']) && isset($params['id'])) {
@@ -343,14 +361,14 @@ function _civicrm_api3_setting_getDomainArray(&$params) {
     if (isset($domainAPIResult['values'])) {
       $params['domain_id'] = array_keys($domainAPIResult['values']);
     }
-    else{
+    else {
       throw new Exception('All domains not retrieved - problem with Domain Get api call ' . $domainAPIResult['error_message']);
     }
   }
   if (is_array($params['domain_id'])) {
     $domains = $params['domain_id'];
   }
-  else{
+  else {
     $domains = array($params['domain_id']);
   }
   return $domains;