PHP Class Piwik\Notification

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;
Show file Open project: piwik/piwik

Public Properties

Property Type Description
$context string A notification's context determines how it will be styled.
$flags integer Usage: $notification->flags = Notification::FLAG_BAR | Notification::FLAG_FOO.
$message string The notification message. Must be set.
$priority integer The notification's priority. The higher the priority, the higher the order. See PRIORITY_* constants in {@link Notification} to see possible priority values.
$raw boolean If true, the message will not be escaped before being outputted as HTML. If you set this to true, make sure you escape text yourself in order to avoid XSS vulnerabilities.
$title string The notification title. The title is optional and is displayed directly before the message content.
$type string The notification's display type. See TYPE_* constants in {@link Notification}.

Public Methods

Method Description
__construct ( string $message ) Constructor.
getPriority ( ) : integer Returns the notification's priority. If no priority has been set, a priority will be set based on the notification's context.
hasNoClear ( ) : integer Returns 1 if the notification will be displayed without a close button, 0 if otherwise.

Method Details

__construct() public method

Constructor.
public __construct ( string $message )
$message string The notification message.

getPriority() public method

Returns the notification's priority. If no priority has been set, a priority will be set based on the notification's context.
public getPriority ( ) : integer
return integer

hasNoClear() public method

Returns 1 if the notification will be displayed without a close button, 0 if otherwise.
public hasNoClear ( ) : integer
return integer `1` or `0`.

Property Details

$context public property

A notification's context determines how it will be styled.
public string $context
return string

$flags public property

Usage: $notification->flags = Notification::FLAG_BAR | Notification::FLAG_FOO.
public int $flags
return integer

$message public property

The notification message. Must be set.
public string $message
return string

$priority public property

The notification's priority. The higher the priority, the higher the order. See PRIORITY_* constants in {@link Notification} to see possible priority values.
public int $priority
return integer

$raw public property

If true, the message will not be escaped before being outputted as HTML. If you set this to true, make sure you escape text yourself in order to avoid XSS vulnerabilities.
public bool $raw
return boolean

$title public property

The notification title. The title is optional and is displayed directly before the message content.
public string $title
return string

$type public property

The notification's display type. See TYPE_* constants in {@link Notification}.
public string $type
return string