Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@gmail.com>2013-10-26 04:48:54 +0400
committerThomas Steur <thomas.steur@gmail.com>2013-10-26 04:48:54 +0400
commit7b5943a94a57cfc45cc4452735e667f7ddb0796b (patch)
tree8d8b97d0f7d97583e5fb56818b0ee86755829065 /core/Notification
parent145fcb57614297bc9be5cbb9597c0820416640be (diff)
refs #4179 started to work on notifications
Diffstat (limited to 'core/Notification')
-rw-r--r--core/Notification/Manager.php66
1 files changed, 66 insertions, 0 deletions
diff --git a/core/Notification/Manager.php b/core/Notification/Manager.php
new file mode 100644
index 0000000000..6f798fded2
--- /dev/null
+++ b/core/Notification/Manager.php
@@ -0,0 +1,66 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ * @category Piwik
+ * @package Piwik
+ */
+namespace Piwik\Notification;
+
+use Piwik\Notification;
+use Piwik\Session\SessionNamespace;
+
+/**
+ * @package Piwik
+ * @subpackage Notification
+ * @api
+ */
+class Manager
+{
+ private static $session = null;
+
+ /**
+ * Post a notification to be shown in the status bar. If a notification with the same id has already been posted by your application and has not yet been canceled, it will be replaced by the updated information.
+ *
+ * @param string $id A unique identifier for this notification
+ * @param Notification $notification
+ */
+ public static function notify($id, Notification $notification)
+ {
+ $session = static::getSession();
+ $session->$id = $notification;
+
+ $session->setExpirationHops(1, $id);
+ }
+
+ public static function getAll()
+ {
+ $session = static::getSession();
+ return $session->getIterator();
+ }
+
+ /**
+ * Cancel a previously registered notification.
+ * @param $id
+ */
+ public static function cancel($id)
+ {
+ $session = static::getSession();
+ unset($session->$id);
+ }
+
+ /**
+ * @return SessionNamespace
+ */
+ private static function getSession()
+ {
+ if (!isset(static::$session)) {
+ static::$session = new SessionNamespace('notification');
+ }
+
+ return static::$session;
+ }
+} \ No newline at end of file