From: Jan Schneider Date: Thu, 6 May 2010 10:21:18 +0000 (+0200) Subject: Add objects storage for notifications, that simply keeps the notifications in X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=231e494b97fefdf39ceddae93332ac990e547a43;p=horde.git Add objects storage for notifications, that simply keeps the notifications in the current storage instance. Helpful for testing and any cases where we are sure that the notifications will be returned in the same request, so that we can close the session to allow more concurrent requests (keyword ajax). --- diff --git a/framework/Notification/lib/Horde/Notification/Storage/Object.php b/framework/Notification/lib/Horde/Notification/Storage/Object.php new file mode 100644 index 000000000..3ac6d41fa --- /dev/null +++ b/framework/Notification/lib/Horde/Notification/Storage/Object.php @@ -0,0 +1,93 @@ + + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Notification + */ + +/** + * A class that stores notifications in an object. + * + * Copyright 2010 The Horde Project (http://www.horde.org/) + * + * See the enclosed file COPYING for license information (LGPL). If you + * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html. + * + * @category Horde + * @package Notification + * @author Jan Schneider + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @link http://pear.horde.org/index.php?package=Notification + */ +class Horde_Notification_Storage_Session +implements Horde_Notification_Storage_Interface +{ + /** + * Holds the notifications pushed into this storage object. + * + * @var array + */ + protected $_notifications = array(); + + /** + * Return the given stack by reference from the notification store. + * + * @param string $key The key for the data. + * + * @return mixed The notification data stored for the given key. + */ + public function &get($key) + { + return $this->_notifications[$key]; + } + + /** + * Set the given stack in the notification store. + * + * @param string $key The key for the data. + * @param mixed $value The data. + */ + public function set($key, $value) + { + $this->_notifications[$key] = $value; + } + + /** + * Is the given stack present in the notification store? + * + * @param string $key The key of the data. + * + * @return boolean True if the element is set, false otherwise. + */ + public function exists($key) + { + return isset($this->_notifications[$key]); + } + + /** + * Unset the given stack in the notification store. + * + * @param string $key The key of the data. + */ + public function clear($key) + { + unset($this->_notifications[$key]); + } + + /** + * Store a new event for the given listener stack. + * + * @param string $listener The event will be stored for + * this listener. + * @param Notification_Event_Listener $event The event to store. + */ + public function push($listener, Notification_Event_Listener $event) + { + $this->_notifications[$listener][] = $event; + } + +} diff --git a/framework/Notification/lib/Horde/Notification/Storage/Session.php b/framework/Notification/lib/Horde/Notification/Storage/Session.php index 4dcdadc3a..54c7341e6 100644 --- a/framework/Notification/lib/Horde/Notification/Storage/Session.php +++ b/framework/Notification/lib/Horde/Notification/Storage/Session.php @@ -31,7 +31,7 @@ implements Horde_Notification_Storage_Interface * * @var string */ - private $_stack; + protected $_stack; /** * Constructor. @@ -100,7 +100,7 @@ implements Horde_Notification_Storage_Interface * this listener. * @param Notification_Event_Listener $event The event to store. */ - public function push($listener, $event) + public function push($listener, Notification_Event_Listener $event) { /* No need to serialize() ourselves - PHP's session handling does * this automatically. */ diff --git a/framework/Notification/package.xml b/framework/Notification/package.xml index cf8186761..e70dba110 100644 --- a/framework/Notification/package.xml +++ b/framework/Notification/package.xml @@ -50,6 +50,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> + @@ -126,6 +127,7 @@ http://pear.php.net/dtd/package-2.0.xsd"> +