mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-23 08:03:49 +00:00
twig extension for listing notification on a given entity
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MainBundle\Notification\Templating;
|
||||
|
||||
use Chill\MainBundle\Notification\NotificationPresence;
|
||||
use Twig\Environment;
|
||||
use Twig\Extension\RuntimeExtensionInterface;
|
||||
|
||||
class NotificationTwigExtensionRuntime implements RuntimeExtensionInterface
|
||||
{
|
||||
private NotificationPresence $notificationPresence;
|
||||
|
||||
public function __construct(NotificationPresence $notificationPresence)
|
||||
{
|
||||
$this->notificationPresence = $notificationPresence;
|
||||
}
|
||||
|
||||
public function listNotificationsFor(Environment $environment, string $relatedEntityClass, int $relatedEntityId, array $options = []): string
|
||||
{
|
||||
$notifications = $this->notificationPresence->getNotificationsForClassAndEntity($relatedEntityClass, $relatedEntityId);
|
||||
|
||||
if ([] === $notifications) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return $environment->render('@ChillMain/Notification/extension_list_notifications_for.html.twig', [
|
||||
'notifications' => $notifications,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user