Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / EventManager / GlobalEventManager.php
blob047dd18cf42eb4bbbc838591761f76c75eccc318
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\EventManager;
12 use Zend\Stdlib\CallbackHandler;
13 use Zend\Stdlib\PriorityQueue;
15 /**
16 * Event manager: notification system
18 * Use the EventManager when you want to create a per-instance notification
19 * system for your objects.
21 class GlobalEventManager
23 /**
24 * @var EventManagerInterface
26 protected static $events;
28 /**
29 * Set the event collection on which this will operate
31 * @param null|EventManagerInterface $events
32 * @return void
34 public static function setEventCollection(EventManagerInterface $events = null)
36 static::$events = $events;
39 /**
40 * Get event collection on which this operates
42 * @return EventManagerInterface
44 public static function getEventCollection()
46 if (null === static::$events) {
47 static::setEventCollection(new EventManager());
49 return static::$events;
52 /**
53 * Trigger an event
55 * @param string $event
56 * @param object|string $context
57 * @param array|object $argv
58 * @return ResponseCollection
60 public static function trigger($event, $context, $argv = array())
62 return static::getEventCollection()->trigger($event, $context, $argv);
65 /**
66 * Trigger listeners until return value of one causes a callback to evaluate
67 * to true.
69 * @param string $event
70 * @param string|object $context
71 * @param array|object $argv
72 * @param callable $callback
73 * @return ResponseCollection
75 public static function triggerUntil($event, $context, $argv, $callback)
77 return static::getEventCollection()->triggerUntil($event, $context, $argv, $callback);
80 /**
81 * Attach a listener to an event
83 * @param string $event
84 * @param callable $callback
85 * @param int $priority
86 * @return CallbackHandler
88 public static function attach($event, $callback, $priority = 1)
90 return static::getEventCollection()->attach($event, $callback, $priority);
93 /**
94 * Detach a callback from a listener
96 * @param CallbackHandler $listener
97 * @return bool
99 public static function detach(CallbackHandler $listener)
101 return static::getEventCollection()->detach($listener);
105 * Retrieve list of events this object manages
107 * @return array
109 public static function getEvents()
111 return static::getEventCollection()->getEvents();
115 * Retrieve all listeners for a given event
117 * @param string $event
118 * @return PriorityQueue|array
120 public static function getListeners($event)
122 return static::getEventCollection()->getListeners($event);
126 * Clear all listeners for a given event
128 * @param string $event
129 * @return void
131 public static function clearListeners($event)
133 static::getEventCollection()->clearListeners($event);