diff --git a/src/Bundle/ChillMainBundle/Entity/Address.php b/src/Bundle/ChillMainBundle/Entity/Address.php index dcf0c5a96..070d40468 100644 --- a/src/Bundle/ChillMainBundle/Entity/Address.php +++ b/src/Bundle/ChillMainBundle/Entity/Address.php @@ -60,6 +60,8 @@ class Address /** * @var string|null * + * used for the CEDEX information + * * @ORM\Column(type="string", length=255, nullable=true) * @Groups({"write"}) */ diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig index 4d871404f..7f1be7c23 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/address.html.twig @@ -25,6 +25,7 @@
{{ address.postCode.code }} {{ address.postCode.name }} + {{ address.distribution }}
{{ address.postCode.country.name|localize_translatable_string }}
{% endif %} @@ -60,6 +61,7 @@{{ address.postCode.code }} {{ address.postCode.name }} + {{ address.distribution }}
{{ address.postCode.country.name|localize_translatable_string }}
{% endif %} @@ -118,6 +120,7 @@{{ address.postCode.code }} {{ address.postCode.name }} + {{ address.distribution }}
{{ address.postCode.country.name|localize_translatable_string }}
diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php index 1af5607c9..04b8234d8 100644 --- a/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php +++ b/src/Bundle/ChillMainBundle/Templating/Entity/AddressRender.php @@ -36,6 +36,36 @@ class AddressRender implements ChillEntityRenderInterface $this->templating = $templating; } + /** + * @param Address addr + * @param mixed $addr + * @return string[] + */ + public function renderLines($addr): array + { + $lines = []; + + $lines[0] = $this->renderBuildingLine($addr); + $lines[1] = $this->renderDeliveryLine($addr); + $lines[2] = $this->renderStreetLine($addr); + $lines[3] = $this->renderCityLine($addr); + $lines[4] = $this->renderCountryLine($addr); + + if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) { + if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') { + $lines[0] = $this->renderIntraBuildingLine($addr); + $lines[1] = $this->renderBuildingLine($addr); + $lines[2] = $this->renderStreetLine($addr); + $lines[3] = $this->renderDeliveryLine($addr); + $lines[4] = $this->renderCityLine($addr); + $lines[5] = $this->renderCountryLine($addr); + } + } + + return $lines; + } + + /** * @param Address addr * @param mixed $addr @@ -62,14 +92,9 @@ class AddressRender implements ChillEntityRenderInterface $lines = []; $lines[0] = $this->renderStreetLine($addr); + $lines[1] = $this->renderCityLine($addr); - if (!empty($addr->getPostcode())) { - $lines[1] = strtr('{postcode} {label}', [ - '{postcode}' => $addr->getPostcode()->getCode(), - '{label}' => $addr->getPostcode()->getName(), - ]); - } - + //TODO simply replace this by a call to renderLines to get all other lines??? return implode(' - ', $lines); } @@ -106,4 +131,25 @@ class AddressRender implements ChillEntityRenderInterface return $res; } + + private function renderCityLine($addr): string + { + + if (!empty($addr->getPostcode())) { + $res = strtr('{postcode} {label}', [ + '{postcode}' => $addr->getPostcode()->getCode(), + '{label}' => $addr->getPostcode()->getName(), + ]); + } + + if (null !== $addr->getPostCode()->getCountry()->getCountryCode()) { + if ($addr->getPostCode()->getCountry()->getCountryCode() === 'FR') { + if ($addr->getDistribution()) { + $res.$addr->getDistribution(); + } + } + } + + return $res; + } }