mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
notification: fix NotificationHandlerInterface
This commit is contained in:
parent
f76f7a1641
commit
d31661ae7a
@ -25,12 +25,12 @@ final class ActivityNotificationHandler implements NotificationHandlerInterface
|
|||||||
$this->activityRepository = $activityRepository;
|
$this->activityRepository = $activityRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplate()
|
public function getTemplate(array $options = []): string
|
||||||
{
|
{
|
||||||
return '@ChillActivity/Activity/showInNotification.html.twig';
|
return '@ChillActivity/Activity/showInNotification.html.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplateData(Notification $notification)
|
public function getTemplateData(Notification $notification, array $options = []): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'notification' => $notification,
|
'notification' => $notification,
|
||||||
|
@ -11,6 +11,22 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\MainBundle\Notification;
|
namespace Chill\MainBundle\Notification;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Entity\Notification;
|
||||||
|
|
||||||
interface NotificationHandlerInterface
|
interface NotificationHandlerInterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Return the template path (twig file).
|
||||||
|
*/
|
||||||
|
public function getTemplate(array $options = []): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return an array which will be passed as data for the template.
|
||||||
|
*/
|
||||||
|
public function getTemplateData(Notification $notification, array $options = []): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return true if the handler supports the handling for this notification.
|
||||||
|
*/
|
||||||
|
public function supports(Notification $notification, array $options = []): bool;
|
||||||
}
|
}
|
||||||
|
@ -32,10 +32,10 @@ final class NotificationHandlerManager
|
|||||||
/**
|
/**
|
||||||
* @throw NotificationHandlerNotFound if handler is not found
|
* @throw NotificationHandlerNotFound if handler is not found
|
||||||
*/
|
*/
|
||||||
public function getHandler(Notification $notification): NotificationHandlerInterface
|
public function getHandler(Notification $notification, array $options = []): NotificationHandlerInterface
|
||||||
{
|
{
|
||||||
foreach ($this->handlers as $renderer) {
|
foreach ($this->handlers as $renderer) {
|
||||||
if ($renderer->supports($notification)) {
|
if ($renderer->supports($notification, $options)) {
|
||||||
return $renderer;
|
return $renderer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,13 +43,13 @@ final class NotificationHandlerManager
|
|||||||
throw new NotificationHandlerNotFound();
|
throw new NotificationHandlerNotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplate(Notification $notification): string
|
public function getTemplate(Notification $notification, array $options = []): string
|
||||||
{
|
{
|
||||||
return $this->getHandler($notification)->getTemplate();
|
return $this->getHandler($notification, $options)->getTemplate($options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplateData(Notification $notification): array
|
public function getTemplateData(Notification $notification, array $options = []): array
|
||||||
{
|
{
|
||||||
return $this->getHandler($notification)->getTemplateData($notification);
|
return $this->getHandler($notification, $options)->getTemplateData($notification, $options);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,12 +25,12 @@ final class AccompanyingPeriodNotificationHandler implements NotificationHandler
|
|||||||
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
|
$this->accompanyingPeriodRepository = $accompanyingPeriodRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplate()
|
public function getTemplate(array $options = []): string
|
||||||
{
|
{
|
||||||
return 'ChillPersonBundle:AccompanyingPeriod:showInNotification.html.twig';
|
return 'ChillPersonBundle:AccompanyingPeriod:showInNotification.html.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getTemplateData(Notification $notification)
|
public function getTemplateData(Notification $notification, array $options = []): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'notification' => $notification,
|
'notification' => $notification,
|
||||||
@ -38,7 +38,7 @@ final class AccompanyingPeriodNotificationHandler implements NotificationHandler
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function supports(Notification $notification)
|
public function supports(Notification $notification, array $options = []): bool
|
||||||
{
|
{
|
||||||
return $notification->getRelatedEntityClass() === AccompanyingPeriod::class;
|
return $notification->getRelatedEntityClass() === AccompanyingPeriod::class;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user