mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
Add UserGroupRender and Interface for UserGroup templating
A new UserGroupRender class was added to manage the templating logic for UserGroup entities. The UserGroupRenderInterface was also created, extending the ChillEntityRenderInterface. Additionally, a Twig template for rendering user groups was added.
This commit is contained in:
parent
e6202a2e34
commit
50025044d3
@ -0,0 +1 @@
|
||||
<span class="badge" style="color: {{ user_group.foregroundColor }}; background-color: {{ user_group.backgroundColor }};">{{ user_group.label|localize_translatable_string }}</span>
|
@ -0,0 +1,38 @@
|
||||
<?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\UserGroup;
|
||||
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
final readonly class UserGroupRender implements UserGroupRenderInterface
|
||||
{
|
||||
public function __construct(private TranslatableStringHelperInterface $translatableStringHelper, private Environment $environment) {}
|
||||
|
||||
public function renderBox($entity, array $options): string
|
||||
{
|
||||
/* @var $entity UserGroup */
|
||||
return $this->environment->render('@ChillMain/Entity/user_group.html.twig', ['user_group' => $entity]);
|
||||
}
|
||||
|
||||
public function renderString($entity, array $options): string
|
||||
{
|
||||
/* @var $entity UserGroup */
|
||||
return $this->translatableStringHelper->localize($entity->getLabel());
|
||||
}
|
||||
|
||||
public function supports(object $entity, array $options): bool
|
||||
{
|
||||
return $entity instanceof UserGroup;
|
||||
}
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
<?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;
|
||||
|
||||
interface UserGroupRenderInterface extends ChillEntityRenderInterface {}
|
@ -51,6 +51,10 @@ services:
|
||||
|
||||
Chill\MainBundle\Templating\Entity\UserRender: ~
|
||||
|
||||
Chill\MainBundle\Templating\Entity\UserGroupRender: ~
|
||||
Chill\MainBundle\Templating\Entity\UserGroupRenderInterface:
|
||||
alias: Chill\MainBundle\Templating\Entity\UserGroupRender
|
||||
|
||||
Chill\MainBundle\Templating\Listing\:
|
||||
resource: './../../Templating/Listing'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user