mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-07 15:25:00 +00:00
docgen normalization for relation
This commit is contained in:
@@ -16,6 +16,8 @@ use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\PersonAltName;
|
||||
use Chill\PersonBundle\Repository\Relationships\RelationRepository;
|
||||
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRender;
|
||||
use DateTimeInterface;
|
||||
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
|
||||
@@ -34,16 +36,20 @@ class PersonDocGenNormalizer implements
|
||||
|
||||
private PersonRender $personRender;
|
||||
|
||||
private RelationshipRepository $relationshipRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
|
||||
public function __construct(
|
||||
PersonRender $personRender,
|
||||
RelationshipRepository $relationshipRepository,
|
||||
TranslatorInterface $translator,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->personRender = $personRender;
|
||||
$this->relationshipRepository = $relationshipRepository;
|
||||
$this->translator = $translator;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
@@ -94,6 +100,18 @@ class PersonDocGenNormalizer implements
|
||||
);
|
||||
}
|
||||
|
||||
if ($context['docgen:person:with-relations'] ?? false) {
|
||||
$data['relations'] = $this->normalizer->normalize(
|
||||
$this->relationshipRepository->findByPerson($person),
|
||||
$format,
|
||||
array_merge($context, [
|
||||
'docgen:person:with-household' => false,
|
||||
'docgen:person:with-relation' => false,
|
||||
'docgen:relationship:counterpart' => $person
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user