class MessageService (View source)

Constants

private TYPE_ERROR

Methods

__construct(UserContextService|null $userContextService = null)

No description

void
addMessage(string $script, string $type, string $content, string|null $recordName = null)

Add a message to be displayed for a specific script Prevents duplicate messages from being added

array|null
getMessages(string $script)

Get messages for a specific script and clear them from session

void
addSystemError(string $error, string|null $recordName = null)

Add a system error message that will be displayed in the proper place in the HTML

withRecordContext(string $recordName)

Set record name context for the error message

dontExit()

Don't exit the script after displaying the error

void
displayDirectSystemError(string $error)

Display a system error directly with basic HTML Useful for critical errors before the header/footer can be rendered

string
generateFormToken()

Generate a unique form token

void
storeFormData(string $token, array $data)

Store form data with a specific token

array|null
getFormData(string $token)

Get stored form data for a token and remove it from the session

void
cleanupFormData()

Clean up expired form data

Details

__construct(UserContextService|null $userContextService = null)

No description

Parameters

UserContextService|null $userContextService

void addMessage(string $script, string $type, string $content, string|null $recordName = null)

Add a message to be displayed for a specific script Prevents duplicate messages from being added

Parameters

string $script

The script to set the message for

string $type

The type of message (error, warning, success, info)

string $content

The content of the message

string|null $recordName

Optional record name for context

Return Value

void

array|null getMessages(string $script)

Get messages for a specific script and clear them from session

Parameters

string $script

The script to get messages for

Return Value

array|null

The messages for the script, or null if no messages are set

void addSystemError(string $error, string|null $recordName = null)

Add a system error message that will be displayed in the proper place in the HTML

Parameters

string $error

The error message to display

string|null $recordName

Optional record name for context

Return Value

void

MessageService withRecordContext(string $recordName)

Set record name context for the error message

Parameters

string $recordName

The record name to provide context for

Return Value

MessageService

For method chaining

MessageService dontExit()

Don't exit the script after displaying the error

Return Value

MessageService

For method chaining

void displayDirectSystemError(string $error)

Display a system error directly with basic HTML Useful for critical errors before the header/footer can be rendered

Parameters

string $error

The error message to display

Return Value

void

string generateFormToken()

Generate a unique form token

Return Value

string

The generated token

void storeFormData(string $token, array $data)

Store form data with a specific token

Parameters

string $token

The form token

array $data

The form data to store

Return Value

void

array|null getFormData(string $token)

Get stored form data for a token and remove it from the session

Parameters

string $token

The form token

Return Value

array|null

The stored form data or null if none exists

void cleanupFormData()

Clean up expired form data

Return Value

void