'type' => CRM_Utils_Type::T_TEXT,
);
}
+
/**
* Adjust Metadata for Get action.
*
* @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'));
}
*/
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) {
* @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);
$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;
}
}
}
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;
}