From: Chris Burgess Date: Wed, 14 Sep 2016 12:28:07 +0000 (+1200) Subject: Coding standards / cleanup. X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=210737b60389720906ec8ed86450c383204dabba;p=civicrm-core.git Coding standards / cleanup. --- diff --git a/api/v3/Address.php b/api/v3/Address.php index 86feb4211f..bcc15c6d36 100644 --- a/api/v3/Address.php +++ b/api/v3/Address.php @@ -116,6 +116,7 @@ function _civicrm_api3_address_create_spec(&$params) { 'type' => CRM_Utils_Type::T_TEXT, ); } + /** * Adjust Metadata for Get action. * diff --git a/api/v3/Attachment.php b/api/v3/Attachment.php index fc9366fc24..62402722f2 100644 --- a/api/v3/Attachment.php +++ b/api/v3/Attachment.php @@ -105,9 +105,8 @@ function _civicrm_api3_attachment_create_spec(&$spec) { * @see Civi\API\Subscriber\DynamicFKAuthorization */ function civicrm_api3_attachment_create($params) { - if (empty($params['id'])) { - // When creating we need either entity_table or field_name + // When creating we need either entity_table or field_name. civicrm_api3_verify_one_mandatory($params, NULL, array('entity_table', 'field_name')); } diff --git a/api/v3/LocBlock.php b/api/v3/LocBlock.php index 0db1cd3492..868ddd0a1f 100644 --- a/api/v3/LocBlock.php +++ b/api/v3/LocBlock.php @@ -45,10 +45,20 @@ */ function civicrm_api3_loc_block_create($params) { $entities = array(); - civicrm_api3_verify_one_mandatory($params, NULL, array('address', 'address_id', 'phone', 'phone_id', 'im', 'im_id', 'email', 'email_id')); - // Call the appropriate api to create entities if any are passed in the params + $any_mandatory = array( + 'address', + 'address_id', + 'phone', + 'phone_id', + 'im', + 'im_id', + 'email', + 'email_id' + ); + civicrm_api3_verify_one_mandatory($params, NULL, $any_mandatory); + // Call the appropriate api to create entities if any are passed in the params. // This is basically chaining but in reverse - we create the sub-entities first - // This exists because chainging does not work in reverse, or with keys like 'email_2' + // because chaining does not work in reverse, or with keys like 'email_2'. $items = array('address', 'email', 'phone', 'im'); foreach ($items as $item) { foreach (array('', '_2') as $suf) { diff --git a/api/v3/utils.php b/api/v3/utils.php index b11f4f2a55..55d4b97222 100644 --- a/api/v3/utils.php +++ b/api/v3/utils.php @@ -72,7 +72,6 @@ function civicrm_api3_verify_one_mandatory($params, $daoName = NULL, $keyoptions * @throws \API_Exception */ function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array(), $verifyDAO = TRUE) { - $unmatched = array(); if ($daoName != NULL && $verifyDAO && empty($params['id'])) { $unmatched = _civicrm_api3_check_required_fields($params, $daoName, TRUE); @@ -99,7 +98,7 @@ function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array() $optionset[] = $subkey; } else { - // as long as there is one match then we don't need to rtn anything + // As long as there is one match we don't need to return anything. $match = 1; } } @@ -109,7 +108,7 @@ function civicrm_api3_verify_mandatory($params, $daoName = NULL, $keys = array() } else { // Disallow empty values except for the number zero. - // TODO: create a utility for this since it's needed in many places + // TODO: create a utility for this since it's needed in many places. if (!array_key_exists($key, $params) || (empty($params[$key]) && $params[$key] !== 0 && $params[$key] !== '0')) { $unmatched[] = $key; }