summaryrefslogtreecommitdiff
path: root/app/Subscriber/NotificationSubscriber.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-01-16 21:06:36 -0500
committerFrederic Guillot <fred@kanboard.net>2016-01-16 21:06:36 -0500
commit6a7b8ec60f265413ca88878dba6180456257d370 (patch)
tree5b36bf3122d6884cb09b66e623e28768e92ed9ba /app/Subscriber/NotificationSubscriber.php
parent6a0895ef765ea7b83df02bb9789fda7415dee9a5 (diff)
Make sure that some event subscribers are not executed multiple times
Diffstat (limited to 'app/Subscriber/NotificationSubscriber.php')
-rw-r--r--app/Subscriber/NotificationSubscriber.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/app/Subscriber/NotificationSubscriber.php b/app/Subscriber/NotificationSubscriber.php
index 1bde24dd..6c24b08c 100644
--- a/app/Subscriber/NotificationSubscriber.php
+++ b/app/Subscriber/NotificationSubscriber.php
@@ -2,7 +2,6 @@
namespace Kanboard\Subscriber;
-use Kanboard\Core\Base;
use Kanboard\Event\GenericEvent;
use Kanboard\Model\Task;
use Kanboard\Model\Comment;
@@ -10,7 +9,7 @@ use Kanboard\Model\Subtask;
use Kanboard\Model\File;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
-class NotificationSubscriber extends Base implements EventSubscriberInterface
+class NotificationSubscriber extends BaseSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
@@ -35,14 +34,17 @@ class NotificationSubscriber extends Base implements EventSubscriberInterface
public function handleEvent(GenericEvent $event, $event_name)
{
- $event_data = $this->getEventData($event);
+ if (! $this->isExecuted()) {
+ $this->logger->debug('Subscriber executed: '.__CLASS__.'::'.__METHOD__);
+ $event_data = $this->getEventData($event);
- if (! empty($event_data)) {
- if (! empty($event['mention'])) {
- $this->userNotification->sendUserNotification($event['mention'], $event_name, $event_data);
- } else {
- $this->userNotification->sendNotifications($event_name, $event_data);
- $this->projectNotification->sendNotifications($event_data['task']['project_id'], $event_name, $event_data);
+ if (! empty($event_data)) {
+ if (! empty($event['mention'])) {
+ $this->userNotification->sendUserNotification($event['mention'], $event_name, $event_data);
+ } else {
+ $this->userNotification->sendNotifications($event_name, $event_data);
+ $this->projectNotification->sendNotifications($event_data['task']['project_id'], $event_name, $event_data);
+ }
}
}
}