Documentation

MentionsParser
in package

Handles parsing username mentions in forum posts.

Tags
author

Samerton

author

fetch404

version
2.0.0-pr13
license

MIT

Table of Contents

Constants

USER_MENTIONS_REGEX  = '/(?<!\/)@([A-Za-z0-9\-_!.]+)/'

Methods

parse()  : string
Parse the given content to replace @username tags with [user]<id>[/user] bbcode.
parseAndNotify()  : string
Parse the given content to replace @username tags with [user]<id>[/user] bbcode, as well as send notifications to the mentioned users.
getRecipients()  : array<string|int, mixed>
Get users from the database based on the provided nicknames. Filters out users have blocked the author.
replaceWithBbcode()  : string
Replace @username tags with [user]<id>[/user] bbcode.

Constants

USER_MENTIONS_REGEX

private mixed USER_MENTIONS_REGEX = '/(?<!\/)@([A-Za-z0-9\-_!.]+)/'

Methods

parse()

Parse the given content to replace @username tags with [user]<id>[/user] bbcode.

public static parse(int $author_id, string $content) : string
Parameters
$author_id : int

User ID of post/custom page creator.

$content : string

Post/custom page content.

Return values
string

Parsed post content.

parseAndNotify()

Parse the given content to replace @username tags with [user]<id>[/user] bbcode, as well as send notifications to the mentioned users.

public static parseAndNotify(int $author_id, string $content, string $url, string $notificationType, LanguageKey $notificationTitle) : string

Users who are tagged but have blocked the author will not receive notifications.

Parameters
$author_id : int

User ID of post/custom page creator.

$content : string

Post/custom page content.

$url : string
$notificationType : string
$notificationTitle : LanguageKey
Return values
string

Parsed post content.

getRecipients()

Get users from the database based on the provided nicknames. Filters out users have blocked the author.

private static getRecipients(string $content, int $author_id) : array<string|int, mixed>
Parameters
$content : string
$author_id : int
Return values
array<string|int, mixed>

replaceWithBbcode()

Replace @username tags with [user]<id>[/user] bbcode.

private static replaceWithBbcode(string $content, array<string|int, mixed> $receipients) : string
Parameters
$content : string

Post/custom page content.

$receipients : array<string|int, mixed>

Array of user objects (with nickname and ID fields).

Return values
string

Parsed post content.


        
On this page

Search results