#25: Made the SendNotifications job in line with the rest of the notification system's design.

This commit is contained in:
Peter Deltchev 2016-05-27 22:21:35 -07:00
parent ce5b060194
commit fc4ae856f8

View file

@ -56,29 +56,17 @@ class SendNotifications extends Job implements SelfHandling, ShouldQueue
{ {
$this->beforeHandle(); $this->beforeHandle();
// get list of users who are supposed to receive this notification // This variable is set here instead of as a static class variable
$recipients = [User::find(1)]; // to work around a Laravel bug - namely, the SerializesModels trait
// tries (and fails) to serialize static fields.
$drivers = [
PonyfmDriver::class
];
foreach ($recipients as $recipient) { foreach ($drivers as $driver) {
// get drivers that this notification should be delivered through /** @var $driver AbstractDriver */
$drivers = $this->getDriversForNotification($recipient, $this->notificationType); $driver = new $driver;
call_user_func_array([$driver, $this->notificationType], $this->notificationData);
foreach ($drivers as $driver) {
/** @var $driver AbstractDriver */
call_user_func_array([$driver, $this->notificationType], $this->notificationData);
}
} }
} }
/**
* Returns the drivers with which the given user has subscribed to the given
* notification type.
*
* @param User $user
* @param string $notificationType
* @return AbstractDriver[]
*/
private function getDriversForNotification(User $user, string $notificationType) {
return [new PonyfmDriver()];
}
} }