Piwik\Notification\Manager::notify PHP Method

notify() public static method

Posts a notification that will be shown in Piwik's status bar. If a notification with the same ID has been posted and has not been closed/removed, it will be replaced with $notification.
public static notify ( string $id, Notification $notification )
$id string A unique identifier for this notification. The ID must be a valid HTML element ID. It can only contain alphanumeric characters (underscores can be used).
$notification Piwik\Notification The notification to post.
    public static function notify($id, Notification $notification)
    {
        self::checkId($id);
        self::removeOldestNotificationsIfThereAreTooMany();
        self::addNotification($id, $notification);
    }

Usage Example

 protected function write(array $record)
 {
     switch ($record['level']) {
         case Logger::EMERGENCY:
         case Logger::ALERT:
         case Logger::CRITICAL:
         case Logger::ERROR:
             $context = Notification::CONTEXT_ERROR;
             break;
         case Logger::WARNING:
             $context = Notification::CONTEXT_WARNING;
             break;
         default:
             $context = Notification::CONTEXT_INFO;
             break;
     }
     $message = $record['level_name'] . ': ' . htmlentities($record['message']);
     $notification = new Notification($message);
     $notification->context = $context;
     $notification->flags = 0;
     try {
         Manager::notify(Common::getRandomString(), $notification);
     } catch (Zend_Session_Exception $e) {
         // Can happen if this handler is enabled in CLI
         // Silently ignore the error.
     }
 }
All Usage Examples Of Piwik\Notification\Manager::notify