Logidav Docs

NotificationService
in package

Table of Contents

Properties

$em  : EntityManagerInterface

Methods

__construct()  : mixed
getAll()  : array<string|int, mixed>
Retrieves all notifications for the given user.
getById()  : array<string|int, mixed>|false
Retrieves a notification by its ID.
getProcessed()  : array<string|int, mixed>
Retrieves processed notifications for the given user.
getRead()  : array<string|int, mixed>
Retrieves read notifications for the given user.
getUnprocessed()  : array<string|int, mixed>
Retrieves unprocessed notifications for the given user.
getUnread()  : array<string|int, mixed>
Retrieves unread notifications for the given user.
getUnreadOrUnprocessed()  : array<string|int, mixed>
Retrieves unread or unprocessed notifications for the given user.
markAsProcessed()  : bool
Marks a notification as processed by updating the 'read_at' and 'processed_at' timestamps.
markAsRead()  : bool
Marks a notification as read by updating the 'read_at' timestamp.
send()  : bool
Sends a notification to a list of users.
fetchNotifications()  : array<string|int, mixed>
Fetches notifications for the given user based on optional conditions.
getUserIdsFromGroupCodes()  : array<string|int, mixed>
Fetches unique user IDs from a list of group codes.

Properties

Methods

__construct()

public __construct(EntityManagerInterface $entityManager) : mixed
Parameters
$entityManager : EntityManagerInterface

getAll()

Retrieves all notifications for the given user.

public getAll(User $user) : array<string|int, mixed>
Parameters
$user : User

The user for whom all notifications are to be retrieved.

Return values
array<string|int, mixed>

An array of all notifications.

getById()

Retrieves a notification by its ID.

public getById(string $id) : array<string|int, mixed>|false
Parameters
$id : string

The ID of the notification to be retrieved.

Tags
throws
DBALException
Return values
array<string|int, mixed>|false

The notification data as an associative array, or false if no notification is found.

getProcessed()

Retrieves processed notifications for the given user.

public getProcessed(User $user) : array<string|int, mixed>
Parameters
$user : User

The user for whom the processed notifications are to be retrieved.

Return values
array<string|int, mixed>

An array of processed notifications.

getRead()

Retrieves read notifications for the given user.

public getRead(User $user) : array<string|int, mixed>
Parameters
$user : User

The user for whom the read notifications are to be retrieved.

Return values
array<string|int, mixed>

An array of read notifications.

getUnprocessed()

Retrieves unprocessed notifications for the given user.

public getUnprocessed(User $user) : array<string|int, mixed>
Parameters
$user : User

The user for whom the unprocessed notifications are to be retrieved.

Return values
array<string|int, mixed>

An array of unprocessed notifications.

getUnread()

Retrieves unread notifications for the given user.

public getUnread(User $user) : array<string|int, mixed>
Parameters
$user : User

The user for whom the unread notifications are to be retrieved.

Return values
array<string|int, mixed>

An array of unread notifications.

getUnreadOrUnprocessed()

Retrieves unread or unprocessed notifications for the given user.

public getUnreadOrUnprocessed(User $user) : array<string|int, mixed>
Parameters
$user : User

The user for whom the unread or unprocessed notifications are to be retrieved.

Return values
array<string|int, mixed>

An array of unread or unprocessed notifications.

markAsProcessed()

Marks a notification as processed by updating the 'read_at' and 'processed_at' timestamps.

public markAsProcessed(string $id, string $key) : bool
Parameters
$id : string

The ID of the notification to be marked as processed.

$key : string

The key associated with the notification to identify its group.

Tags
throws
DBALException
Return values
bool

True if the update was successful, false otherwise.

markAsRead()

Marks a notification as read by updating the 'read_at' timestamp.

public markAsRead(string $id) : bool
Parameters
$id : string

The ID of the notification to be marked as read.

Tags
throws
DBALException
Return values
bool

True if the update was successful, false otherwise.

send()

Sends a notification to a list of users.

public send(array<string|int, mixed> $groupCodes, string $title, string $body[, string $link = '' ]) : bool
Parameters
$groupCodes : array<string|int, mixed>
$title : string

Title of the notification.

$body : string

Body of the notification.

$link : string = ''

Url if the notification is clickable

Tags
throws
ConnectionException
Return values
bool

Whether the notification was sent successfully or not.

fetchNotifications()

Fetches notifications for the given user based on optional conditions.

private fetchNotifications(User $user[, string $condition = '' ]) : array<string|int, mixed>
Parameters
$user : User

The user for whom notifications are to be fetched.

$condition : string = ''

Additional SQL condition to filter notifications (optional).

Tags
throws
DBALException
Return values
array<string|int, mixed>

An array of fetched notifications.

getUserIdsFromGroupCodes()

Fetches unique user IDs from a list of group codes.

private getUserIdsFromGroupCodes(array<string|int, mixed> $groupCodes) : array<string|int, mixed>
Parameters
$groupCodes : array<string|int, mixed>
Return values
array<string|int, mixed>

        
On this page

Search results