From 50025044d34238e61a0c3209847b9734fbfe6f35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 31 May 2024 12:31:44 +0200 Subject: [PATCH] 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. --- .../views/Entity/user_group.html.twig | 1 + .../Templating/Entity/UserGroupRender.php | 38 +++++++++++++++++++ .../Entity/UserGroupRenderInterface.php | 14 +++++++ .../config/services/templating.yaml | 4 ++ 4 files changed, 57 insertions(+) create mode 100644 src/Bundle/ChillMainBundle/Resources/views/Entity/user_group.html.twig create mode 100644 src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRender.php create mode 100644 src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRenderInterface.php diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/user_group.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/user_group.html.twig new file mode 100644 index 000000000..8504a88dd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/user_group.html.twig @@ -0,0 +1 @@ +{{ user_group.label|localize_translatable_string }} diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRender.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRender.php new file mode 100644 index 000000000..b63fca8cf --- /dev/null +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRender.php @@ -0,0 +1,38 @@ +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; + } +} diff --git a/src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRenderInterface.php b/src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRenderInterface.php new file mode 100644 index 000000000..7ebf70028 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Templating/Entity/UserGroupRenderInterface.php @@ -0,0 +1,14 @@ +