mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
person: add person ressource to person docgen normaliser
This commit is contained in:
parent
5e0a693108
commit
e7299bac4a
@ -117,6 +117,27 @@ class PersonResource implements TrackCreationInterface, TrackUpdateInterface
|
||||
return $this->person;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Groups({"read"})
|
||||
*/
|
||||
public function getResourceKind(): string
|
||||
{
|
||||
if ($this->getPerson() instanceof Person) {
|
||||
return 'person';
|
||||
}
|
||||
|
||||
if ($this->getThirdParty() instanceof ThirdParty) {
|
||||
return 'thirdparty';
|
||||
}
|
||||
|
||||
if (null !== $this->getFreeText()) {
|
||||
return 'freetext';
|
||||
}
|
||||
|
||||
return 'none';
|
||||
}
|
||||
|
||||
|
||||
public function getPersonOwner(): ?Person
|
||||
{
|
||||
return $this->personOwner;
|
||||
|
@ -18,6 +18,7 @@ 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\PersonResourceRepository;
|
||||
use Chill\PersonBundle\Repository\Relationships\RelationshipRepository;
|
||||
use Chill\PersonBundle\Templating\Entity\PersonRenderInterface;
|
||||
use DateTimeInterface;
|
||||
@ -41,6 +42,8 @@ class PersonDocGenNormalizer implements
|
||||
|
||||
private RelationshipRepository $relationshipRepository;
|
||||
|
||||
private PersonResourceRepository $personResourceRepository;
|
||||
|
||||
private TranslatableStringHelper $translatableStringHelper;
|
||||
|
||||
private TranslatorInterface $translator;
|
||||
@ -48,11 +51,13 @@ class PersonDocGenNormalizer implements
|
||||
public function __construct(
|
||||
PersonRenderInterface $personRender,
|
||||
RelationshipRepository $relationshipRepository,
|
||||
PersonResourceRepository $personResourceRepository,
|
||||
TranslatorInterface $translator,
|
||||
TranslatableStringHelper $translatableStringHelper
|
||||
) {
|
||||
$this->personRender = $personRender;
|
||||
$this->relationshipRepository = $relationshipRepository;
|
||||
$this->personResourceRepository = $personResourceRepository;
|
||||
$this->translator = $translator;
|
||||
$this->translatableStringHelper = $translatableStringHelper;
|
||||
}
|
||||
@ -104,8 +109,9 @@ class PersonDocGenNormalizer implements
|
||||
'memo' => $person->getMemo(),
|
||||
'numberOfChildren' => (string) $person->getNumberOfChildren(),
|
||||
'address' => $this->normalizer->normalize($person->getCurrentPersonAddress(), $format, $addressContext),
|
||||
'resources' => $this->personResourceRepository->findBy(['personOwner' => $person]),
|
||||
];
|
||||
|
||||
dump($data);
|
||||
if ($context['docgen:person:with-household'] ?? false) {
|
||||
$data['household'] = $this->normalizer->normalize(
|
||||
$person->getCurrentHousehold(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user