PHP Class Flarum\Core\Notification\NotificationSyncer

Show file Open project: flarum/core Class Usage Examples

Protected Properties

Property Type Description
$mailer NotificationMailer
$notifications Flarum\Core\Repository\NotificationRepository
$onePerUser boolean Whether or not notifications are being limited to one per user.
$sentTo int[] An internal list of user IDs that notifications have been sent to.

Public Methods

Method Description
__construct ( NotificationRepository $notifications, NotificationMailer $mailer )
delete ( Flarum\Core\Notification\BlueprintInterface $blueprint ) : void Delete a notification for all users.
onePerUser ( callable $callback ) : void Limit notifications to one per user for the entire duration of the given callback.
restore ( Flarum\Core\Notification\BlueprintInterface $blueprint ) : void Restore a notification for all users.
sync ( Flarum\Core\Notification\BlueprintInterface $blueprint, array $users ) : void 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.

Protected Methods

Method Description
getAttributes ( Flarum\Core\Notification\BlueprintInterface $blueprint ) : array Construct an array of attributes to be stored in a notification record in the database, given a notification blueprint.
mailNotifications ( Flarum\Core\Notification\MailableInterface $blueprint, array $recipients ) Mail a notification to a list of users.
sendNotifications ( Flarum\Core\Notification\BlueprintInterface $blueprint, array $recipients ) Create a notification record and send an email (depending on user preference) from a blueprint to a list of recipients.
setDeleted ( array $ids, boolean $isDeleted ) Set the deleted status of a list of notification records.

Method Details

__construct() public method

public __construct ( NotificationRepository $notifications, NotificationMailer $mailer )
$notifications Flarum\Core\Repository\NotificationRepository
$mailer NotificationMailer

delete() public method

Delete a notification for all users.
public delete ( Flarum\Core\Notification\BlueprintInterface $blueprint ) : void
$blueprint Flarum\Core\Notification\BlueprintInterface
return void

getAttributes() protected method

Construct an array of attributes to be stored in a notification record in the database, given a notification blueprint.
protected getAttributes ( Flarum\Core\Notification\BlueprintInterface $blueprint ) : array
$blueprint Flarum\Core\Notification\BlueprintInterface
return array

mailNotifications() protected method

Mail a notification to a list of users.
protected mailNotifications ( Flarum\Core\Notification\MailableInterface $blueprint, array $recipients )
$blueprint Flarum\Core\Notification\MailableInterface
$recipients array

onePerUser() public method

Limit notifications to one per user for the entire duration of the given callback.
public onePerUser ( callable $callback ) : void
$callback callable
return void

restore() public method

Restore a notification for all users.
public restore ( Flarum\Core\Notification\BlueprintInterface $blueprint ) : void
$blueprint Flarum\Core\Notification\BlueprintInterface
return void

sendNotifications() protected method

Create a notification record and send an email (depending on user preference) from a blueprint to a list of recipients.
protected sendNotifications ( Flarum\Core\Notification\BlueprintInterface $blueprint, array $recipients )
$blueprint Flarum\Core\Notification\BlueprintInterface
$recipients array

setDeleted() protected method

Set the deleted status of a list of notification records.
protected setDeleted ( array $ids, boolean $isDeleted )
$ids array
$isDeleted boolean

sync() public method

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.
public sync ( Flarum\Core\Notification\BlueprintInterface $blueprint, array $users ) : void
$blueprint Flarum\Core\Notification\BlueprintInterface
$users array
return void

Property Details

$mailer protected property

protected NotificationMailer,Flarum\Core\Notification $mailer
return NotificationMailer

$notifications protected property

protected NotificationRepository,Flarum\Core\Repository $notifications
return Flarum\Core\Repository\NotificationRepository

$onePerUser protected static property

Whether or not notifications are being limited to one per user.
protected static bool $onePerUser
return boolean

$sentTo protected static property

An internal list of user IDs that notifications have been sent to.
protected static int[] $sentTo
return int[]