mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
improve layout of third parties in AddPerson
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
namespace Chill\ThirdPartyBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
|
||||
@@ -12,19 +13,27 @@ class ThirdPartyNormalizer implements NormalizerInterface, NormalizerAwareInterf
|
||||
{
|
||||
use NormalizerAwareTrait;
|
||||
|
||||
private ThirdPartyRender $thirdPartyRender;
|
||||
|
||||
public function __construct(ThirdPartyRender $thirdPartyRender)
|
||||
{
|
||||
$this->thirdPartyRender = $thirdPartyRender;
|
||||
}
|
||||
|
||||
public function normalize($thirdParty, string $format = null, array $context = [])
|
||||
{
|
||||
/** @var $thirdParty ThirdParty */
|
||||
$data['type'] = 'thirdparty';
|
||||
// TODO should be replaced by a "render entity"
|
||||
$data['text'] = $thirdParty->getName();
|
||||
$data['text'] = $this->thirdPartyRender->renderString($thirdParty, []);
|
||||
$data['id'] = $thirdParty->getId();
|
||||
$data['kind'] = $thirdParty->getKind();
|
||||
$data['address'] = $this->normalizer->normalize($thirdParty->getAddress(), $format,
|
||||
[ 'address_rendering' => 'short' ]);
|
||||
$data['phonenumber'] = $thirdParty->getTelephone();
|
||||
$data['email'] = $thirdParty->getEmail();
|
||||
$data['isChild'] = $thirdParty->isChild();
|
||||
$data['parent'] = $this->normalizer->normalize($thirdParty->getParent(), $format, $context);
|
||||
$data['civility'] = $this->normalizer->normalize($thirdParty->getCivility(), $format, $context);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
Reference in New Issue
Block a user