adding age in renderbox and renderstring, implementation of renderbox option in household summary

This commit is contained in:
Julie Lenaerts 2022-01-27 12:33:50 +01:00
parent ff66aa5590
commit af3847366b
3 changed files with 19 additions and 1 deletions

View File

@ -11,6 +11,7 @@
* addCenter bool
* hLevel integer
* addDeath bool
* addAgeBadge bool
* address_multiline bool
* customButtons [
'before' Twig\Markup, (injected with macro)
@ -40,6 +41,11 @@
{%- endfor -%}
</span>
{%- endif -%}
{%- if options['addAgeBadge'] -%}
{% if person.age is not null and person.deathDate is null %}
<span class="age">({{- 'years_old'|trans({ 'age': person.age }) -}})</span>
{% endif %}
{% endif %}
{% endmacro raw %}
{% macro label(person, options) %}

View File

@ -14,6 +14,7 @@
'render': 'label',
'addLink': true,
'addInfo': true,
'addAgeBadge': true,
'customArea': {
'afterLabel': _self.addHolder(member.holder)
}

View File

@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
use Chill\PersonBundle\Entity\Person;
use Symfony\Component\Templating\EngineInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
use function array_key_exists;
@ -27,12 +28,16 @@ class PersonRender extends AbstractChillEntityRender
private EngineInterface $engine;
private TranslatorInterface $translator;
public function __construct(
ConfigPersonAltNamesHelper $configAltNamesHelper,
EngineInterface $engine
EngineInterface $engine,
TranslatorInterface $translator
) {
$this->configAltNamesHelper = $configAltNamesHelper;
$this->engine = $engine;
$this->translator = $translator;
}
/**
@ -53,6 +58,7 @@ class PersonRender extends AbstractChillEntityRender
'customButtons' => $options['customButtons'] ?? [],
'customArea' => $options['customArea'] ?? [],
'addDeath' => $options['addDeath'] ?? true,
'addAgeBadge' => $options['addAgeBadge'] ?? false,
];
return
@ -70,6 +76,11 @@ class PersonRender extends AbstractChillEntityRender
*/
public function renderString($person, array $options): string
{
if (null !== $person->getAge() && $person->getDeathDate() === null) {
return $person->getFirstName() . ' ' . $person->getLastName()
. $this->addAltNames($person, false) . ' (' . $this->translator->trans('years_old', ['age' => $person->getAge()]) . ')';
}
return $person->getFirstName() . ' ' . $person->getLastName()
. $this->addAltNames($person, false);
}