Merge pull request #20907 from atm-quentin/NEW_hook_format_address

FIX : hook for dol_format_address
This commit is contained in:
Laurent Destailleur 2022-05-21 00:42:11 +02:00 committed by GitHub
commit 1196d6f48c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2154,7 +2154,7 @@ function dol_bc($var, $moreclass = '')
*/
function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs = '', $mode = 0, $extralangcode = '')
{
global $conf, $langs;
global $conf, $langs, $hookmanager;
$ret = '';
$countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
@ -2220,6 +2220,14 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
$langs->load("dict");
$ret .= (empty($object->country_code) ? '' : ($ret ? $sep : '').$outputlangs->convToOutputCharset($outputlangs->transnoentitiesnoconv("Country".$object->country_code)));
}
if ($hookmanager) {
$parameters = array('withcountry' => $withcountry, 'sep' => $sep, 'outputlangs' => $outputlangs,'mode' => $mode, 'extralangcode' => $extralangcode);
$reshook = $hookmanager->executeHooks('formatAddress', $parameters, $object);
if ($reshook > 0) {
$ret = '';
}
$ret .= $hookmanager->resPrint;
}
return $ret;
}