mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 11:33:49 +00:00
main: change address format for France, in Address render box and normalizer
This commit is contained in:
@@ -46,6 +46,7 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
return $this->templating
|
||||
->render('@ChillMain/Entity/address.html.twig', [
|
||||
'address' => $addr,
|
||||
'streetLine' => $this->renderStreetLine($addr),
|
||||
'render' => $options['render'] ?? 'bloc',
|
||||
'options' => $options,
|
||||
]);
|
||||
@@ -59,13 +60,7 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
{
|
||||
$lines = [];
|
||||
|
||||
if (!empty($addr->getStreet())) {
|
||||
$lines[0] = $addr->getStreet();
|
||||
}
|
||||
|
||||
if (!empty($addr->getStreetNumber())) {
|
||||
$lines[0] .= ', ' . $addr->getStreetNumber();
|
||||
}
|
||||
$lines[0] = $this->renderStreetLine($addr);
|
||||
|
||||
if (!empty($addr->getPostcode())) {
|
||||
$lines[1] = strtr('{postcode} {label}', [
|
||||
@@ -81,4 +76,33 @@ class AddressRender implements ChillEntityRenderInterface
|
||||
{
|
||||
return $entity instanceof Address;
|
||||
}
|
||||
|
||||
private function renderStreetLine($addr): string
|
||||
{
|
||||
if (!empty($addr->getStreet())) {
|
||||
$street = $addr->getStreet();
|
||||
} else {
|
||||
$street = '';
|
||||
}
|
||||
|
||||
if (!empty($addr->getStreetNumber())) {
|
||||
$streetNumber = $addr->getStreetNumber();
|
||||
} else {
|
||||
$streetNumber = '';
|
||||
}
|
||||
|
||||
$res = trim($street . ', ' . $streetNumber, ', ');
|
||||
|
||||
if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) {
|
||||
if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') {
|
||||
$res = trim($streetNumber . ', ' . $street, ', ');
|
||||
}
|
||||
}
|
||||
|
||||
if (',' === $res) {
|
||||
$res = '';
|
||||
}
|
||||
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user