mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
adding age in renderbox and renderstring, implementation of renderbox option in household summary
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user