[*] CORE : AddressFormat, Add the possibility to doesn't specify a patternRules (avoid type) and fix empty content
This commit is contained in:
@@ -348,7 +348,7 @@ class AddressFormatCore extends ObjectModel
|
|||||||
* @newLine is a string containing the newLine format
|
* @newLine is a string containing the newLine format
|
||||||
* @separator is a string containing the separator format
|
* @separator is a string containing the separator format
|
||||||
*/
|
*/
|
||||||
public static function generateAddress(Address $address, $patternRules, $newLine = "\r\n", $separator = ' ', $style = array())
|
public static function generateAddress(Address $address, $patternRules = array(), $newLine = "\r\n", $separator = ' ', $style = array())
|
||||||
{
|
{
|
||||||
$addressFields = AddressFormat::getOrderedAddressFields($address->id_country);
|
$addressFields = AddressFormat::getOrderedAddressFields($address->id_country);
|
||||||
$addressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($address, $addressFields);
|
$addressFormatedValues = AddressFormat::getFormattedAddressFieldsValues($address, $addressFields);
|
||||||
@@ -359,8 +359,9 @@ class AddressFormatCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
$tmpText = '';
|
$tmpText = '';
|
||||||
foreach($patternsList as $pattern)
|
foreach($patternsList as $pattern)
|
||||||
if (!in_array($pattern, $patternRules['avoid']))
|
if ((!array_key_exists('avoid', $patternRules)) ||
|
||||||
$tmpText .= (isset($addressFormatedValues[$pattern])) ?
|
(array_key_exists('avoid', $patternRules) && !in_array($pattern, $patternRules['avoid'])))
|
||||||
|
$tmpText .= (isset($addressFormatedValues[$pattern]) && !empty($addressFormatedValues[$pattern])) ?
|
||||||
(((isset($style[$pattern])) ?
|
(((isset($style[$pattern])) ?
|
||||||
(sprintf($style[$pattern], $addressFormatedValues[$pattern])) :
|
(sprintf($style[$pattern], $addressFormatedValues[$pattern])) :
|
||||||
$addressFormatedValues[$pattern]).$separator) : '';
|
$addressFormatedValues[$pattern]).$separator) : '';
|
||||||
|
|||||||
Reference in New Issue
Block a user