mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Use renderInterface to render gender icons in twig
This commit is contained in:
parent
de914f4f17
commit
43dd94dad6
@ -16,7 +16,7 @@
|
||||
<tr>
|
||||
<td>{{ entity.id }}</td>
|
||||
<td>{{ entity.label|localize_translatable_string }}</td>
|
||||
<td><i class="{{ entity.icon }}"></i></td>
|
||||
<td>{{ entity.icon|chill_entity_render_box }}</td>
|
||||
<td>{{ entity.genderTranslation.value }}</td>
|
||||
<td style="text-align:center;">
|
||||
{%- if entity.active -%}
|
||||
|
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\MainBundle\Templating\Entity;
|
||||
|
||||
use Chill\MainBundle\Entity\GenderIconEnum;
|
||||
use Chill\MainBundle\Entity\NewsItem;
|
||||
|
||||
/**
|
||||
* @implements ChillEntityRenderInterface<GenderIconEnum>
|
||||
*/
|
||||
final readonly class ChillGenderIconRender implements ChillEntityRenderInterface
|
||||
{
|
||||
public function renderBox($icon, array $options): string
|
||||
{
|
||||
return
|
||||
'<i class="'. $icon->value .'"></i>';
|
||||
}
|
||||
|
||||
public function renderString($icon, array $options): string
|
||||
{
|
||||
return $icon->value;
|
||||
}
|
||||
|
||||
public function supports($icon, array $options): bool
|
||||
{
|
||||
return $icon instanceof GenderIconEnum;
|
||||
}
|
||||
}
|
@ -49,6 +49,8 @@ services:
|
||||
|
||||
Chill\MainBundle\Templating\Entity\NewsItemRender: ~
|
||||
|
||||
Chill\MainBundle\Templating\Entity\ChillGenderIconRender: ~
|
||||
|
||||
Chill\MainBundle\Templating\Entity\UserRender: ~
|
||||
|
||||
Chill\MainBundle\Templating\Listing\:
|
||||
|
@ -86,7 +86,8 @@
|
||||
</div>
|
||||
{%- if options['addInfo'] -%}
|
||||
<p class="moreinfo">
|
||||
<i class="{{ person.gender.icon }}" title="{{ person.gender.label|localize_translatable_string }}"></i>
|
||||
{{ person.gender.icon|chill_entity_render_box }}
|
||||
{# <i class="{{ person.gender.icon.value }}" title="{{ person.gender.label|localize_translatable_string }}"></i>#}
|
||||
|
||||
{%- if person.deathdate is not null -%}
|
||||
{%- if person.birthdate is not null -%}
|
||||
|
Loading…
x
Reference in New Issue
Block a user