mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-11-04 11:18:25 +00:00 
			
		
		
		
	adding age in renderbox and renderstring, implementation of renderbox option in household summary
This commit is contained in:
		@@ -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) %}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@
 | 
			
		||||
                'render': 'label',
 | 
			
		||||
                'addLink': true,
 | 
			
		||||
                'addInfo': true,
 | 
			
		||||
                'addAgeBadge': true,
 | 
			
		||||
                'customArea': {
 | 
			
		||||
                    'afterLabel': _self.addHolder(member.holder)
 | 
			
		||||
                }
 | 
			
		||||
 
 | 
			
		||||
@@ -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