mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
Merge branch 'master' into notification/completion
This commit is contained in:
@@ -13,6 +13,7 @@ namespace Chill\MainBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\DocGeneratorBundle\Serializer\Helper\NormalizeNullValueHelper;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
use Chill\MainBundle\Templating\Entity\AddressRender;
|
||||
use DateTimeInterface;
|
||||
use Symfony\Component\Serializer\Exception\UnexpectedValueException;
|
||||
use Symfony\Component\Serializer\Normalizer\AbstractNormalizer;
|
||||
@@ -46,6 +47,13 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
'validTo' => DateTimeInterface::class,
|
||||
];
|
||||
|
||||
private AddressRender $addressRender;
|
||||
|
||||
public function __construct(AddressRender $addressRender)
|
||||
{
|
||||
$this->addressRender = $addressRender;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Address $address
|
||||
* @param string|null $format
|
||||
@@ -53,19 +61,9 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
public function normalize($address, $format = null, array $context = [])
|
||||
{
|
||||
if ($address instanceof Address) {
|
||||
$text = $address->isNoAddress() ? '' : $address->getStreet() . ', ' . $address->getStreetNumber();
|
||||
|
||||
if (null !== $address->getPostCode()->getCountry()->getCountryCode()) {
|
||||
if ($address->getPostCode()->getCountry()->getCountryCode() === 'FR') {
|
||||
$text = $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet();
|
||||
} else {
|
||||
$text = $address->isNoAddress() ? '' : $address->getStreetNumber() . ', ' . $address->getStreet();
|
||||
}
|
||||
}
|
||||
|
||||
$data = [
|
||||
'address_id' => $address->getId(),
|
||||
'text' => $text,
|
||||
'text' => $address->isNoAddress() ? null : $this->addressRender->renderStreetLine($address, []),
|
||||
'street' => $address->getStreet(),
|
||||
'streetNumber' => $address->getStreetNumber(),
|
||||
'postcode' => [
|
||||
@@ -85,6 +83,7 @@ class AddressNormalizer implements ContextAwareNormalizerInterface, NormalizerAw
|
||||
'buildingName' => $address->getBuildingName(),
|
||||
'distribution' => $address->getDistribution(),
|
||||
'extra' => $address->getExtra(),
|
||||
'lines' => $this->addressRender->renderLines($address),
|
||||
];
|
||||
|
||||
if ('json' === $format) {
|
||||
|
Reference in New Issue
Block a user