[ Index ] |
PHP Cross Reference of phpBB-3.2.11-deutsch |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework (http://framework.zend.com/) 4 * 5 * @link http://github.com/zendframework/zf2 for the canonical source repository 6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 7 * @license http://framework.zend.com/license/new-bsd New BSD License 8 */ 9 10 namespace Zend\EventManager; 11 12 use Zend\Stdlib\CallbackHandler; 13 use Zend\Stdlib\PriorityQueue; 14 15 /** 16 * Event manager: notification system 17 * 18 * Use the EventManager when you want to create a per-instance notification 19 * system for your objects. 20 */ 21 class GlobalEventManager 22 { 23 /** 24 * @var EventManagerInterface 25 */ 26 protected static $events; 27 28 /** 29 * Set the event collection on which this will operate 30 * 31 * @param null|EventManagerInterface $events 32 * @return void 33 */ 34 public static function setEventCollection(EventManagerInterface $events = null) 35 { 36 static::$events = $events; 37 } 38 39 /** 40 * Get event collection on which this operates 41 * 42 * @return EventManagerInterface 43 */ 44 public static function getEventCollection() 45 { 46 if (null === static::$events) { 47 static::setEventCollection(new EventManager()); 48 } 49 return static::$events; 50 } 51 52 /** 53 * Trigger an event 54 * 55 * @param string $event 56 * @param object|string $context 57 * @param array|object $argv 58 * @param null|callable $callback 59 * @return ResponseCollection 60 */ 61 public static function trigger($event, $context, $argv = array(), $callback = null) 62 { 63 return static::getEventCollection()->trigger($event, $context, $argv, $callback); 64 } 65 66 /** 67 * Trigger listeners until return value of one causes a callback to evaluate 68 * to true. 69 * 70 * @param string $event 71 * @param string|object $context 72 * @param array|object $argv 73 * @param callable $callback 74 * @return ResponseCollection 75 * @deprecated Please use trigger() 76 */ 77 public static function triggerUntil($event, $context, $argv, $callback) 78 { 79 trigger_error( 80 'This method is deprecated and will be removed in the future. Please use trigger() instead.', 81 E_USER_DEPRECATED 82 ); 83 return static::trigger($event, $context, $argv, $callback); 84 } 85 86 /** 87 * Attach a listener to an event 88 * 89 * @param string $event 90 * @param callable $callback 91 * @param int $priority 92 * @return CallbackHandler 93 */ 94 public static function attach($event, $callback, $priority = 1) 95 { 96 return static::getEventCollection()->attach($event, $callback, $priority); 97 } 98 99 /** 100 * Detach a callback from a listener 101 * 102 * @param CallbackHandler $listener 103 * @return bool 104 */ 105 public static function detach(CallbackHandler $listener) 106 { 107 return static::getEventCollection()->detach($listener); 108 } 109 110 /** 111 * Retrieve list of events this object manages 112 * 113 * @return array 114 */ 115 public static function getEvents() 116 { 117 return static::getEventCollection()->getEvents(); 118 } 119 120 /** 121 * Retrieve all listeners for a given event 122 * 123 * @param string $event 124 * @return PriorityQueue|array 125 */ 126 public static function getListeners($event) 127 { 128 return static::getEventCollection()->getListeners($event); 129 } 130 131 /** 132 * Clear all listeners for a given event 133 * 134 * @param string $event 135 * @return void 136 */ 137 public static function clearListeners($event) 138 { 139 static::getEventCollection()->clearListeners($event); 140 } 141 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Nov 11 20:33:01 2020 | Cross-referenced by PHPXref 0.7.1 |