person: add person ressource to person docgen normaliser

This commit is contained in:
nobohan 2022-03-17 19:07:11 +01:00
parent 5e0a693108
commit e7299bac4a
2 changed files with 28 additions and 1 deletions

View File

@ -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;

View File

@ -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(),