1: <?php
2: /**
3: * The Horde_Notification:: class provides a subject-observer pattern for
4: * raising and showing messages of different types and to different
5: * listeners.
6: *
7: * Copyright 2001-2012 Horde LLC (http://www.horde.org/)
8: *
9: * See the enclosed file COPYING for license information (LGPL). If you
10: * did not receive this file, see http://www.horde.org/licenses/lgpl21.
11: *
12: * @author Jan Schneider <jan@horde.org>
13: * @category Horde
14: * @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
15: * @package Notification
16: */
17: class Horde_Notification
18: {
19: /**
20: * Horde_Notification instances.
21: *
22: * @var Horde_Notification
23: */
24: static protected $_instances = array();
25:
26: /**
27: * Returns a reference to the global notification handler, only
28: * creating it if it doesn't already exist.
29: *
30: * This method must be invoked as:
31: * $notification = Horde_Notification::singleton([$stack]);
32: *
33: * @param string $stack The name of the message stack to use.
34: *
35: * return Horde_Notification_Handler The Horde Notification handler.
36: */
37: static public function singleton($stack = 'horde_notification_stacks')
38: {
39: if (!isset(self::$_instances[$stack])) {
40: self::$_instances[$stack] = new Horde_Notification_Handler(new Horde_Notification_Storage_Session($stack));
41: }
42:
43: return self::$_instances[$stack];
44: }
45:
46: }
47: