class NotificationSyncer

The Notification Syncer commits notification blueprints to the database, and sends them via email depending on user preference. Where a blueprint represents a single notification, the syncer associates it with a particular user(s) and makes it available in their inbox.

Properties

static protected bool $onePerUser <p>Whether or not notifications are being limited to one per user.</p>
static protected int[] $sentTo <p>An internal list of user IDs that notifications have been sent to.</p>
protected NotificationRepository $notifications
protected NotificationMailer $mailer

Methods

__construct(NotificationRepository $notifications, NotificationMailer $mailer)

No description

void
sync(BlueprintInterface $blueprint, array $users)

<p>Sync a notification so that it is visible to the specified users, and not visible to anyone else. If it is being made visible for the first time, attempt to send the user an email.</p>

void
delete(BlueprintInterface $blueprint)

<p>Delete a notification for all users.</p>

void
restore(BlueprintInterface $blueprint)

<p>Restore a notification for all users.</p>

void
onePerUser(callable $callback)

<p>Limit notifications to one per user for the entire duration of the given callback.</p>

sendNotifications(BlueprintInterface $blueprint, array $recipients)

<p>Create a notification record and send an email (depending on user preference) from a blueprint to a list of recipients.</p>

mailNotifications(MailableInterface $blueprint, array $recipients)

<p>Mail a notification to a list of users.</p>

setDeleted(array $ids, bool $isDeleted)

<p>Set the deleted status of a list of notification records.</p>

array
getAttributes(BlueprintInterface $blueprint)

<p>Construct an array of attributes to be stored in a notification record in the database, given a notification blueprint.</p>

Details

__construct(NotificationRepository $notifications, NotificationMailer $mailer)

Parameters

NotificationRepository $notifications
NotificationMailer $mailer

void sync(BlueprintInterface $blueprint, array $users)

<p>Sync a notification so that it is visible to the specified users, and not visible to anyone else. If it is being made visible for the first time, attempt to send the user an email.</p>

Parameters

BlueprintInterface $blueprint
array $users

Return Value

void

void delete(BlueprintInterface $blueprint)

<p>Delete a notification for all users.</p>

Parameters

BlueprintInterface $blueprint

Return Value

void

void restore(BlueprintInterface $blueprint)

<p>Restore a notification for all users.</p>

Parameters

BlueprintInterface $blueprint

Return Value

void

void onePerUser(callable $callback)

<p>Limit notifications to one per user for the entire duration of the given callback.</p>

Parameters

callable $callback

Return Value

void

protected sendNotifications(BlueprintInterface $blueprint, array $recipients)

<p>Create a notification record and send an email (depending on user preference) from a blueprint to a list of recipients.</p>

Parameters

BlueprintInterface $blueprint
array $recipients

protected mailNotifications(MailableInterface $blueprint, array $recipients)

<p>Mail a notification to a list of users.</p>

Parameters

MailableInterface $blueprint
array $recipients

protected setDeleted(array $ids, bool $isDeleted)

<p>Set the deleted status of a list of notification records.</p>

Parameters

array $ids
bool $isDeleted

protected array getAttributes(BlueprintInterface $blueprint)

<p>Construct an array of attributes to be stored in a notification record in the database, given a notification blueprint.</p>

Parameters

BlueprintInterface $blueprint

Return Value

array