You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In my App/Providers/EventServiceProvider.php, I was listening to the NotificationSending event to do some checks before sending a notification as follows:
After I installed this package, my App\Listeners\NotificationSendingListener does not seem to work.
I believe, it is being overridden by the package because the package is listening to the same event as:
Maybe the same array key issue and the first value gets overridden by the second.
As the protected $listen is an associative array and using the same array key results in the last key-value pair actually being registered and ignoring any previous ones.
Found the reason causing this issue.
As we know the listener LiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener checks if the user has unsubscribed from the notification and returns false which suppress that notification from being processed and sent out to the user. All good here.
But if user has not unsubscribed from the notification, this class returns $event.
And this causes the other listeners for the same event NotificationSending not processed.
Solution
Returning void return; instead of return $event in the handle method of LiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener class resolves the issue.
@liran-co I'll open a pull request soon for a review.
The text was updated successfully, but these errors were encountered:
77media-creations
changed the title
This package overrides the NotificationSending listener
The package doesn't let you use the NotificationSending listener in the app
Aug 20, 2022
In my
App/Providers/EventServiceProvider.php
, I was listening to theNotificationSending
event to do some checks before sending a notification as follows:After I installed this package, my
App\Listeners\NotificationSendingListener
does not seem to work.I believe, it is being overridden by the package because the package is listening to the same event as:
Maybe the same array key issue and the first value gets overridden by the second.
As the
protected $listen
is an associative array and using the same array key results in the last key-value pair actually being registered and ignoring any previous ones.Found the reason causing this issue.
As we know the listener
LiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener
checks if the user has unsubscribed from the notification and returnsfalse
which suppress that notification from being processed and sent out to the user. All good here.But if user has not unsubscribed from the notification, this class returns
$event
.And this causes the other listeners for the same event
NotificationSending
not processed.Solution
Returning void
return;
instead ofreturn $event
in the handle method ofLiranCo\NotificationSubscriptions\Listeners\NotificationSendingListener
class resolves the issue.@liran-co I'll open a pull request soon for a review.
The text was updated successfully, but these errors were encountered: