notification: create

This commit is contained in:
2021-12-25 22:41:25 +01:00
parent d62893827b
commit 11824adda4
10 changed files with 210 additions and 26 deletions

View File

@@ -13,8 +13,8 @@ namespace Chill\MainBundle\Notification;
use Chill\ActivityBundle\Notification\ActivityNotificationRenderer;
use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\Exception\NotificationHandlerNotFound;
use Chill\PersonBundle\Notification\AccompanyingPeriodNotificationRenderer;
use Exception;
final class NotificationHandlerManager
{
@@ -31,17 +31,7 @@ final class NotificationHandlerManager
$this->renderers[] = $activityNotificationRenderer;
}
public function getTemplate(Notification $notification)
{
return $this->getRenderer($notification)->getTemplate();
}
public function getTemplateData(Notification $notification)
{
return $this->getRenderer($notification)->getTemplateData($notification);
}
private function getRenderer(Notification $notification)
public function getHandler(Notification $notification): NotificationHandlerInterface
{
foreach ($this->renderers as $renderer) {
if ($renderer->supports($notification)) {
@@ -49,6 +39,16 @@ final class NotificationHandlerManager
}
}
throw new Exception('No renderer for ' . $notification);
throw new NotificationHandlerNotFound();
}
public function getTemplate(Notification $notification)
{
return $this->getHandler($notification)->getTemplate();
}
public function getTemplateData(Notification $notification)
{
return $this->getHandler($notification)->getTemplateData($notification);
}
}