class message_service implements message_service_interface

internal  
 

Message Service.

Facade for Moodle's messaging and email subsystems with token replacement support.

Constants

COMPONENT

NAME

Methods

void
email(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0, array|null $attachments = null)

Send an email message using Moodle's messaging subsystem.

mixed
message(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0)

Send an in-app message.

mixed
notification(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0, mixed $url = null, string|null $urlname = null)

Send a notification (non-reply) message.

mixed
prepare(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0)

Prepare a core message payload.

int
get_conversation_id(mixed $message)

Retrieve the conversation identifier for a prepared message.

array
prepare_text(mixed $course, mixed $user)

Build placeholder replacements for user/course context.

Details

at line 61
void email(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0, array|null $attachments = null)

Send an email message using Moodle's messaging subsystem.

Parameters

mixed $from

Sender descriptor (user or address)

mixed $to

Recipient descriptor (user or address)

string $subject

Email subject

string $text

Email body

int $courseid

Course context for messaging

array|null $attachments

Optional list of attachments

Return Value

void

Exceptions

moodle_exception

at line 103
mixed message(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0)

Send an in-app message.

Parameters

mixed $from

Sender descriptor (user or address)

mixed $to

Recipient descriptor (user or address)

string $subject

Message subject

string $text

Message body

int $courseid

Course context for messaging

Return Value

mixed

Implementation-defined result of the send operation

Exceptions

moodle_exception

at line 139
mixed notification(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0, mixed $url = null, string|null $urlname = null)

Send a notification (non-reply) message.

Parameters

mixed $from

Sender descriptor (user or address)

mixed $to

Recipient descriptor (user or address)

string $subject

Notification subject

string $text

Notification body

int $courseid

Course context for messaging

mixed $url

Optional URL payload

string|null $urlname

Optional URL label

Return Value

mixed

Implementation-defined result of the send operation

Exceptions

moodle_exception

at line 182
mixed prepare(mixed $from, mixed $to, string $subject, string $text, int $courseid = 0)

Prepare a core message payload.

Parameters

mixed $from

Sender descriptor (user or address)

mixed $to

Recipient descriptor (user or address)

string $subject

Message subject

string $text

Message body

int $courseid

Course context for messaging

Return Value

mixed

Prepared message structure

at line 210
int get_conversation_id(mixed $message)

Retrieve the conversation identifier for a prepared message.

Parameters

mixed $message

Prepared message structure

Return Value

int

Conversation identifier

at line 225
array prepare_text(mixed $course, mixed $user)

Build placeholder replacements for user/course context.

Parameters

mixed $course

Course reference

mixed $user

User reference

Return Value

array

Prepared text placeholders

Exceptions

moodle_exception