interface message_service_interface

Public contract for the message_service facade.

Extensions depend ONLY on this interface — never on the core implementation. No Moodle/Core dependencies are allowed inside this contract.

Methods

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

Send an email message.

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

Send a Moodle message (non-notification).

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

Send a Moodle notification.

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

Prepare a structured message object.

int
get_conversation_id(mixed $message)

Get or create a conversation ID for a message.

array
prepare_text(mixed $course, mixed $user)

Replace template variables in a message.

Details

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

Send an email message.

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

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

Send a Moodle message (non-notification).

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

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

Send a Moodle notification.

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

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

Prepare a structured message object.

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 115
int get_conversation_id(mixed $message)

Get or create a conversation ID for a message.

Parameters

mixed $message

Prepared message structure

Return Value

int

Conversation identifier

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

Replace template variables in a message.

Parameters

mixed $course

Course reference

mixed $user

User reference

Return Value

array

Prepared text placeholders