Documentation

Notification
in package

Notification class to handle sending notifications to a user or users Notifications can be alerts or emails

Tags
author

Samerton

version
2.2.0
license

MIT

Table of Contents

Properties

$_authorId  : int
$_recipients  : array<string|int, mixed>
$_skipPurify  : bool
$_title  : string
$_type  : string
$_types  : array<string|int, mixed>

Methods

__construct()  : mixed
Instantiate a new notification
addType()  : void
Register a custom notification type
getTypes()  : array<string|int, mixed>
Returns all registered notification types
send()  : void
sendAlert()  : void
sendEmail()  : void

Properties

$_recipients

private array<string|int, mixed> $_recipients = []

$_types

private static array<string|int, mixed> $_types = []

Methods

__construct()

Instantiate a new notification

public __construct(string $type, string $title, string $content, int|array<string|int, int> $recipients, int $authorId[, callable|null $contentCallback = null ][, bool $skipPurify = false ]) : mixed
Parameters
$type : string

Type of notification

$title : string

Title of notification

$content : string

Notification content

$recipients : int|array<string|int, int>

Notification recipient or recipients - array of user IDs

$authorId : int

User ID that sent the notification

$contentCallback : callable|null = null

Optional callback to perform for each recipient's content

$skipPurify : bool = false

Whether to skip content purifying, default false

Tags
throws
NotificationTypeNotFoundException

addType()

Register a custom notification type

public static addType(string $type, string $value, int $moduleId) : void
Parameters
$type : string
$value : string

Human readable

$moduleId : int

getTypes()

Returns all registered notification types

public static getTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

sendAlert()

private sendAlert(int $userId, string $content) : void
Parameters
$userId : int
$content : string

sendEmail()

private sendEmail(int $userId, string $content) : void
Parameters
$userId : int
$content : string

        
On this page

Search results