Use centerResolverDispatcher to normalize a person's center

This commit is contained in:
2021-11-08 12:22:11 +00:00
parent 19b469259d
commit 7399d0aa9e
3 changed files with 20 additions and 6 deletions

View File

@@ -78,7 +78,7 @@
{{ $t('renderbox.no_data') }}
</p>
</li>
<li v-if="person.mobilenumber">
<i class="fa fa-li fa-mobile"></i>
<a :href="'tel: ' + person.mobilenumber">{{ person.mobilenumber }}</a>
@@ -97,8 +97,13 @@
</li>
<li v-if="person.center && options.addCenter">
<i class="fa fa-li fa-long-arrow-right"></i>
{{ person.center.name }}
<i class="fa fa-li fa-long-arrow-right"></i>
<template v-if="person.center.type !== undefined">
{{ person.center.name }}
</template>
<template v-else>
<template v-for="c in person.center">{{ c.name }}</template>
</template>
</li>
<li v-else-if="options.addNoData">
<i class="fa fa-li fa-long-arrow-right"></i>

View File

@@ -19,6 +19,7 @@
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher;
use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Serializer\Normalizer\DenormalizerAwareInterface;
@@ -48,16 +49,22 @@ class PersonNormalizer implements
private PersonRepository $repository;
private CenterResolverDispatcher $centerResolverDispatcher;
use NormalizerAwareTrait;
use ObjectToPopulateTrait;
use DenormalizerAwareTrait;
public function __construct(ChillEntityRenderExtension $render, PersonRepository $repository)
{
public function __construct(
ChillEntityRenderExtension $render,
PersonRepository $repository,
CenterResolverDispatcher $centerResolverDispatcher
) {
$this->render = $render;
$this->repository = $repository;
$this->centerResolverDispatcher = $centerResolverDispatcher;
}
public function normalize($person, string $format = null, array $context = array())
@@ -74,7 +81,7 @@ class PersonNormalizer implements
'lastName' => $person->getLastName(),
'birthdate' => $this->normalizer->normalize($person->getBirthdate()),
'deathdate' => $this->normalizer->normalize($person->getDeathdate()),
'center' => $this->normalizer->normalize($person->getCenter()),
'center' => $this->normalizer->normalize($this->centerResolverDispatcher->resolveCenter($person)),
'phonenumber' => $person->getPhonenumber(),
'mobilenumber' => $person->getMobilenumber(),
'altNames' => $this->normalizeAltNames($person->getAltNames()),