1 | <?php |
||
51 | class Event |
||
52 | { |
||
53 | /** |
||
54 | * All registered events. |
||
55 | * |
||
56 | * @var array |
||
57 | */ |
||
58 | protected static $events = array(); |
||
59 | |||
60 | /** |
||
61 | * Determine if an event has any registered listeners. |
||
62 | * |
||
63 | * @param string $event |
||
64 | * |
||
65 | * @return bool |
||
66 | */ |
||
67 | public static function listeners($event) |
||
71 | |||
72 | /** |
||
73 | * Register a callback for a given event. |
||
74 | * |
||
75 | * @param string $event |
||
76 | * @param mixed $callback |
||
77 | * |
||
78 | * @return void |
||
79 | */ |
||
80 | public static function listen($event, $callback) |
||
84 | |||
85 | /** |
||
86 | * Override all callbacks for a given event with a new callback. |
||
87 | * |
||
88 | * @param string $event |
||
89 | * @param mixed $callback |
||
90 | * |
||
91 | * @return void |
||
92 | */ |
||
93 | public static function override($event, $callback) |
||
98 | |||
99 | /** |
||
100 | * Clear all event listeners for a given event. |
||
101 | * |
||
102 | * @param string $event |
||
103 | * |
||
104 | * @return void |
||
105 | */ |
||
106 | public static function clear($event) |
||
110 | |||
111 | /** |
||
112 | * Fire an event and return the first response. |
||
113 | * |
||
114 | * @param string $event |
||
115 | * @param \Exception[] $parameters |
||
116 | * |
||
117 | * @return mixed |
||
118 | */ |
||
119 | public static function first($event, $parameters = array()) |
||
125 | |||
126 | /** |
||
127 | * Fire an event and return the first response. |
||
128 | * Execution will be halted after the first valid response is found. |
||
129 | * |
||
130 | * @param string $event |
||
131 | * @param array $parameters |
||
132 | * |
||
133 | * @return mixed |
||
134 | */ |
||
135 | public static function until($event, $parameters = array()) |
||
139 | |||
140 | /** |
||
141 | * Fire an event so that all listeners are called. |
||
142 | * |
||
143 | * @param string $events |
||
144 | * @param array $parameters |
||
145 | * @param bool $halt |
||
146 | * |
||
147 | * @return array|null |
||
148 | */ |
||
149 | public static function fire($events, $parameters = array(), $halt = false) |
||
176 | } |
||
177 |