1 | <?php |
||
12 | class Manager |
||
13 | { |
||
14 | const PRIORITY_URGENT = 0; |
||
15 | const PRIORITY_HIGHEST = 1; |
||
16 | const PRIORITY_HIGH = 2; |
||
17 | const PRIORITY_NORMAL = 3; |
||
18 | const PRIORITY_LOW = 4; |
||
19 | const PRIORITY_LOWEST = 5; |
||
20 | |||
21 | /** |
||
22 | * @internal |
||
23 | * |
||
24 | * @var array Contains registered events and their handlers by priority |
||
25 | * |
||
26 | * @since 1.0 |
||
27 | */ |
||
28 | protected $subscribers = []; |
||
29 | |||
30 | /** |
||
31 | * Determine if the event name has any subscribers. |
||
32 | * |
||
33 | * @api |
||
34 | * |
||
35 | * @param string $eventName The desired event's name |
||
36 | * |
||
37 | * @return bool Whether or not the event was published |
||
38 | * |
||
39 | * @since 1.0 |
||
40 | * |
||
41 | * @version 1.0 |
||
42 | */ |
||
43 | public function hasSubscribers($eventName) |
||
48 | |||
49 | /** |
||
50 | * Determine if the described event has been subscribed to or not by the callback. |
||
51 | * |
||
52 | * @api |
||
53 | * |
||
54 | * @param string $eventName The desired event's name |
||
55 | * @param callable $callback The specific callback we're looking for |
||
56 | * |
||
57 | * @return int|false Subscriber's array index if found, false otherwise; use === |
||
58 | * |
||
59 | * @since 1.0 |
||
60 | * |
||
61 | * @version 1.0 |
||
62 | */ |
||
63 | public function isSubscribed($eventName, callable $callback) |
||
69 | |||
70 | /** |
||
71 | * Handles inserting the new subscriber into the sorted internal array. |
||
72 | * |
||
73 | * @internal |
||
74 | * |
||
75 | * @param string $eventName The event it will listen for |
||
76 | * @param int $interval The timer interval, if it's a timer (0 if not) |
||
77 | * @param array $handler Each individual handler coming from the Observer |
||
78 | * |
||
79 | * @since 1.0 |
||
80 | * |
||
81 | * @version 1.0 |
||
82 | */ |
||
83 | public function add($eventName, $interval, array $handler) |
||
120 | |||
121 | /** |
||
122 | * Takes care of actually calling the event handling functions |
||
123 | * |
||
124 | * @internal |
||
125 | * |
||
126 | * @param string $eventName |
||
127 | * @param Event $event |
||
128 | * @param mixed $result |
||
129 | * |
||
130 | * @since 1.0 |
||
131 | * |
||
132 | * @version 1.0 |
||
133 | */ |
||
134 | public function fire($eventName, Event $event, $result = null) |
||
167 | |||
168 | /** |
||
169 | * |
||
170 | */ |
||
171 | public function remove($eventName) |
||
175 | |||
176 | /** |
||
177 | * |
||
178 | * @param callable $callback |
||
179 | */ |
||
180 | public function searchAndDestroy($eventName, $callback) |
||
202 | |||
203 | /** |
||
204 | * |
||
205 | */ |
||
206 | protected function realign($eventName, $priority, $inc = 1) |
||
212 | |||
213 | /** |
||
214 | * Searches a multi-dimensional array for a value in any dimension. |
||
215 | * |
||
216 | * @internal |
||
217 | * |
||
218 | * @param mixed $needle The value to be searched for |
||
219 | * @param array $haystack The array |
||
220 | * |
||
221 | * @return int|bool The top-level key containing the needle if found, false otherwise |
||
222 | * |
||
223 | * @since 1.0 |
||
224 | * |
||
225 | * @version 1.0 |
||
226 | */ |
||
227 | protected static function arraySearchDeep($needle, array $haystack) |
||
249 | |||
250 | /** |
||
251 | * Returns the current timestamp in milliseconds. |
||
252 | * Named for the similar function in Java. |
||
253 | * |
||
254 | * @internal |
||
255 | * |
||
256 | * @return int Current timestamp in milliseconds |
||
257 | * |
||
258 | * @since 1.0 |
||
259 | * |
||
260 | * @version 1.0 |
||
261 | */ |
||
262 | final protected static function currentTimeMillis() |
||
269 | } |
||
270 |