mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
Adding fonction in personrenderbox
This commit is contained in:
@@ -11,7 +11,10 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\ThirdPartyBundle\Serializer\Normalizer;
|
||||
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdPartyCategory;
|
||||
use Chill\ThirdPartyBundle\Templating\Entity\ThirdPartyRender;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
|
||||
@@ -23,9 +26,14 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
|
||||
|
||||
private ThirdPartyRender $thirdPartyRender;
|
||||
|
||||
public function __construct(ThirdPartyRender $thirdPartyRender)
|
||||
{
|
||||
private TranslatableStringHelperInterface $translatableStringHelper;
|
||||
|
||||
public function __construct(
|
||||
ThirdPartyRender $thirdPartyRender,
|
||||
TranslatableStringHelperInterface $translatableStringHelper
|
||||
) {
|
||||
$this->thirdPartyRender = $thirdPartyRender;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -39,13 +47,26 @@ class ThirdPartyNormalizer implements NormalizerAwareInterface, NormalizerInterf
|
||||
'text' => $this->thirdPartyRender->renderString($thirdParty, []),
|
||||
'id' => $thirdParty->getId(),
|
||||
'kind' => $thirdParty->getKind(),
|
||||
'category' => array_map(function ($el) {
|
||||
if ($el instanceof ThirdPartyCategory) {
|
||||
return [
|
||||
'text' => $this->translatableStringHelper->localize($el->getName()),
|
||||
'type' => 'thirdparty_category',
|
||||
];
|
||||
} else {
|
||||
return [
|
||||
'text' => $el,
|
||||
'type' => 'thirdparty_kind',
|
||||
];
|
||||
}
|
||||
}, $thirdParty->getTypesAndCategories()),
|
||||
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
|
||||
'address' => $this->normalizer->normalize($thirdParty->getAddress(), $format, ['address_rendering' => 'short']),
|
||||
'phonenumber' => $thirdParty->getTelephone(),
|
||||
'email' => $thirdParty->getEmail(),
|
||||
'isChild' => $thirdParty->isChild(),
|
||||
'parent' => $this->normalizer->normalize($thirdParty->getParent(), $format, $context),
|
||||
'civility' => $this->normalizer->normalize($thirdParty->getCivility(), $format, $context),
|
||||
'profession' => $this->normalizer->normalize($thirdParty->getProfession(), $format, $context),
|
||||
'contactDataAnonymous' => $thirdParty->isContactDataAnonymous(),
|
||||
];
|
||||
}
|
||||
|
Reference in New Issue
Block a user