* API result array.
*
* @throws \API_Exception
+ * @throws \CiviCRM_API3_Exception
*/
function civicrm_api3_loc_block_create($params) {
- $entities = array();
- $any_mandatory = array(
+ $entities = [];
+ $any_mandatory = [
'address',
'address_id',
'phone',
'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
// because chaining does not work in reverse, or with keys like 'email_2'.
- $items = array('address', 'email', 'phone', 'im');
+ $items = ['address', 'email', 'phone', 'im'];
foreach ($items as $item) {
- foreach (array('', '_2') as $suf) {
+ foreach (['', '_2'] as $suf) {
$key = $item . $suf;
if (!empty($params[$key]) && is_array($params[$key])) {
$info = $params[$key];
$dao->copyValues($params);
$dao->save();
if (!empty($dao->id)) {
- $values = array($dao->id => $entities);
+ $values = [$dao->id => $entities];
_civicrm_api3_object_to_array($dao, $values[$dao->id]);
return civicrm_api3_create_success($values, $params, 'LocBlock', 'create', $dao);
}
- throw New API_Exception('Unable to create LocBlock. Please check your params.');
+ throw new API_Exception('Unable to create LocBlock. Please check your params.');
}
/**
// This is a helper because api chaining does not work with a key like 'email_2'.
if (!empty($options['return'])) {
unset($params['return']);
- $values = array();
- $items = array('address', 'email', 'phone', 'im');
+ $values = [];
+ $items = ['address', 'email', 'phone', 'im'];
$returnAll = !empty($options['return']['all']);
foreach (_civicrm_api3_basic_get('CRM_Core_DAO_LocBlock', $params, FALSE) as $val) {
foreach ($items as $item) {
- foreach (array('', '_2') as $suf) {
+ foreach (['', '_2'] as $suf) {
$key = $item . $suf;
if (!empty($val[$key . '_id']) && ($returnAll || !empty($options['return'][$key]))) {
- $val[$key] = civicrm_api($item, 'getsingle', array('version' => 3, 'id' => $val[$key . '_id']));
+ $val[$key] = civicrm_api($item, 'getsingle', ['version' => 3, 'id' => $val[$key . '_id']]);
}
}
}