mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
45 lines
1.3 KiB
PHP
45 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Chill\MainBundle\Notification;
|
|
|
|
use Chill\MainBundle\Entity\Notification;
|
|
use Chill\PersonBundle\Notification\AccompanyingPeriodNotificationRenderer;
|
|
use Chill\ActivityBundle\Notification\ActivityNotificationRenderer;
|
|
|
|
final class NotificationRenderer
|
|
{
|
|
private array $renderers;
|
|
|
|
public function __construct(
|
|
AccompanyingPeriodNotificationRenderer $accompanyingPeriodNotificationRenderer,
|
|
ActivityNotificationRenderer $activityNotificationRenderer)
|
|
{
|
|
// TODO configure automatically
|
|
// TODO CREER UNE INTERFACE POUR ETRE SUR QUE LES RENDERERS SONT OK
|
|
|
|
$this->renderers[] = $accompanyingPeriodNotificationRenderer;
|
|
$this->renderers[] = $activityNotificationRenderer;
|
|
}
|
|
|
|
private function getRenderer(Notification $notification)
|
|
{
|
|
foreach ($this->renderers as $renderer) {
|
|
if($renderer->supports($notification)) {
|
|
return $renderer;
|
|
}
|
|
}
|
|
|
|
throw new \Exception('No renderer for '. $notification);
|
|
}
|
|
|
|
public function getTemplate(Notification $notification)
|
|
{
|
|
return $this->getRenderer($notification)->getTemplate();
|
|
}
|
|
|
|
public function getTemplateData(Notification $notification)
|
|
{
|
|
return $this->getRenderer($notification)->getTemplateData($notification);
|
|
}
|
|
}
|