mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
adding age in renderbox and renderstring, implementation of renderbox option in household summary
This commit is contained in:
parent
3fd4c6339a
commit
6ef7d9b47b
@ -11,6 +11,7 @@
|
|||||||
* addCenter bool
|
* addCenter bool
|
||||||
* hLevel integer
|
* hLevel integer
|
||||||
* addDeath bool
|
* addDeath bool
|
||||||
|
* addAgeBadge bool
|
||||||
* address_multiline bool
|
* address_multiline bool
|
||||||
* customButtons [
|
* customButtons [
|
||||||
'before' Twig\Markup, (injected with macro)
|
'before' Twig\Markup, (injected with macro)
|
||||||
@ -40,6 +41,11 @@
|
|||||||
{%- endfor -%}
|
{%- endfor -%}
|
||||||
</span>
|
</span>
|
||||||
{%- endif -%}
|
{%- 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 %}
|
{% endmacro raw %}
|
||||||
|
|
||||||
{% macro label(person, options) %}
|
{% macro label(person, options) %}
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
'render': 'label',
|
'render': 'label',
|
||||||
'addLink': true,
|
'addLink': true,
|
||||||
'addInfo': true,
|
'addInfo': true,
|
||||||
|
'addAgeBadge': true,
|
||||||
'customArea': {
|
'customArea': {
|
||||||
'afterLabel': _self.addHolder(member.holder)
|
'afterLabel': _self.addHolder(member.holder)
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,7 @@ use Chill\MainBundle\Templating\Entity\AbstractChillEntityRender;
|
|||||||
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
use Chill\PersonBundle\Config\ConfigPersonAltNamesHelper;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Symfony\Component\Templating\EngineInterface;
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||||
|
|
||||||
use function array_key_exists;
|
use function array_key_exists;
|
||||||
|
|
||||||
@ -27,12 +28,16 @@ class PersonRender extends AbstractChillEntityRender
|
|||||||
|
|
||||||
private EngineInterface $engine;
|
private EngineInterface $engine;
|
||||||
|
|
||||||
|
private TranslatorInterface $translator;
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
ConfigPersonAltNamesHelper $configAltNamesHelper,
|
ConfigPersonAltNamesHelper $configAltNamesHelper,
|
||||||
EngineInterface $engine
|
EngineInterface $engine,
|
||||||
|
TranslatorInterface $translator
|
||||||
) {
|
) {
|
||||||
$this->configAltNamesHelper = $configAltNamesHelper;
|
$this->configAltNamesHelper = $configAltNamesHelper;
|
||||||
$this->engine = $engine;
|
$this->engine = $engine;
|
||||||
|
$this->translator = $translator;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,6 +58,7 @@ class PersonRender extends AbstractChillEntityRender
|
|||||||
'customButtons' => $options['customButtons'] ?? [],
|
'customButtons' => $options['customButtons'] ?? [],
|
||||||
'customArea' => $options['customArea'] ?? [],
|
'customArea' => $options['customArea'] ?? [],
|
||||||
'addDeath' => $options['addDeath'] ?? true,
|
'addDeath' => $options['addDeath'] ?? true,
|
||||||
|
'addAgeBadge' => $options['addAgeBadge'] ?? false,
|
||||||
];
|
];
|
||||||
|
|
||||||
return
|
return
|
||||||
@ -70,6 +76,11 @@ class PersonRender extends AbstractChillEntityRender
|
|||||||
*/
|
*/
|
||||||
public function renderString($person, array $options): string
|
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()
|
return $person->getFirstName() . ' ' . $person->getLastName()
|
||||||
. $this->addAltNames($person, false);
|
. $this->addAltNames($person, false);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user