UI notifications are messages displayed to the user near the top of the screen.
Notifications consist of a message, a context (the message type), a priority
and a display type.
**The context** affects the way the message looks, but not how it is displayed.
**The display type** determines how the message is displayed.
**The priority** determines where it is shown in the list of all displayed notifications.
### Examples
**Display an error message**
$notification = new Notification('My Error Message');
$notification->context = Notification::CONTEXT_ERROR;
Notification\Manager::notify('myUniqueNotificationId', $notification);
**Display a temporary success message**
$notification = new Notificiation('Success');
$notification->context = Notification::CONTEXT_SUCCESS;
$notification->type = Notification::TYPE_TOAST;
Notification\Manager::notify('myUniqueNotificationId', $notification);
**Display a message near the top of the screen**
$notification = new Notification('Urgent: Your password has expired!');
$notification->context = Notification::CONTEXT_INFO;
$notification->type = Notification::TYPE_PERSISTENT;
$notification->priority = Notification::PRIORITY_MAX;
$context публичное свойство
A notification's context determines how it will be styled.
public string $context |
Результат |
string |
|