From 2d47fb4f4ddd21b7f954f1d140575471fac78740 Mon Sep 17 00:00:00 2001 From: Alexey Skobkin Date: Sat, 7 Jan 2017 21:56:09 +0300 Subject: [PATCH] Telegram bot empty subscribers change notification fix. --- .../PointToolsBundle/Service/SubscriptionsManager.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Skobkin/Bundle/PointToolsBundle/Service/SubscriptionsManager.php b/src/Skobkin/Bundle/PointToolsBundle/Service/SubscriptionsManager.php index 38bf7df..04ae19b 100644 --- a/src/Skobkin/Bundle/PointToolsBundle/Service/SubscriptionsManager.php +++ b/src/Skobkin/Bundle/PointToolsBundle/Service/SubscriptionsManager.php @@ -84,9 +84,11 @@ class SubscriptionsManager // Removing users from database $this->em->getRepository('SkobkinPointToolsBundle:Subscription')->removeSubscribers($user, $unsubscribedList); - // Dispatching event - $subscribersUpdatedEvent = new UserSubscribersUpdatedEvent($user, $subscribedList, $unsubscribedList); - $this->eventDispatcher->dispatch(UserSubscribersUpdatedEvent::NAME, $subscribersUpdatedEvent); + if (0 !== count($subscribedList) || 0 !== count($unsubscribedList)) { + // Dispatching event + $subscribersUpdatedEvent = new UserSubscribersUpdatedEvent($user, $subscribedList, $unsubscribedList); + $this->eventDispatcher->dispatch(UserSubscribersUpdatedEvent::NAME, $subscribersUpdatedEvent); + } } /**