mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
address: render distribution in street line + init renderLines function
This commit is contained in:
parent
78cf817921
commit
3c2ebee12a
@ -60,6 +60,8 @@ class Address
|
|||||||
/**
|
/**
|
||||||
* @var string|null
|
* @var string|null
|
||||||
*
|
*
|
||||||
|
* used for the CEDEX information
|
||||||
|
*
|
||||||
* @ORM\Column(type="string", length=255, nullable=true)
|
* @ORM\Column(type="string", length=255, nullable=true)
|
||||||
* @Groups({"write"})
|
* @Groups({"write"})
|
||||||
*/
|
*/
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
<p class="postcode">
|
<p class="postcode">
|
||||||
<span class="code">{{ address.postCode.code }}</span>
|
<span class="code">{{ address.postCode.code }}</span>
|
||||||
<span class="name">{{ address.postCode.name }}</span>
|
<span class="name">{{ address.postCode.name }}</span>
|
||||||
|
<span class="name">{{ address.distribution }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -60,6 +61,7 @@
|
|||||||
<p class="postcode">
|
<p class="postcode">
|
||||||
<span class="code">{{ address.postCode.code }}</span>
|
<span class="code">{{ address.postCode.code }}</span>
|
||||||
<span class="name">{{ address.postCode.name }}</span>
|
<span class="name">{{ address.postCode.name }}</span>
|
||||||
|
<span class="name">{{ address.distribution }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -118,6 +120,7 @@
|
|||||||
<p class="postcode">
|
<p class="postcode">
|
||||||
<span class="code">{{ address.postCode.code }}</span>
|
<span class="code">{{ address.postCode.code }}</span>
|
||||||
<span class="name">{{ address.postCode.name }}</span>
|
<span class="name">{{ address.postCode.name }}</span>
|
||||||
|
<span class="name">{{ address.distribution }}</span>
|
||||||
</p>
|
</p>
|
||||||
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
<p class="country">{{ address.postCode.country.name|localize_translatable_string }}</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -36,6 +36,36 @@ class AddressRender implements ChillEntityRenderInterface
|
|||||||
$this->templating = $templating;
|
$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 Address addr
|
||||||
* @param mixed $addr
|
* @param mixed $addr
|
||||||
@ -62,14 +92,9 @@ class AddressRender implements ChillEntityRenderInterface
|
|||||||
$lines = [];
|
$lines = [];
|
||||||
|
|
||||||
$lines[0] = $this->renderStreetLine($addr);
|
$lines[0] = $this->renderStreetLine($addr);
|
||||||
|
$lines[1] = $this->renderCityLine($addr);
|
||||||
|
|
||||||
if (!empty($addr->getPostcode())) {
|
//TODO simply replace this by a call to renderLines to get all other lines???
|
||||||
$lines[1] = strtr('{postcode} {label}', [
|
|
||||||
'{postcode}' => $addr->getPostcode()->getCode(),
|
|
||||||
'{label}' => $addr->getPostcode()->getName(),
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return implode(' - ', $lines);
|
return implode(' - ', $lines);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -106,4 +131,25 @@ class AddressRender implements ChillEntityRenderInterface
|
|||||||
|
|
||||||
return $res;
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user