blob: 638610698e68f2114b44a1dbefa257fb69c0bed3 [file] [log] [blame]
Matthias Andreas Benkard7b2a3a12021-08-16 10:57:25 +02001<?php
2
3namespace Illuminate\Contracts\Events;
4
5interface Dispatcher
6{
7 /**
8 * Register an event listener with the dispatcher.
9 *
10 * @param \Closure|string|array $events
11 * @param \Closure|string|array|null $listener
12 * @return void
13 */
14 public function listen($events, $listener = null);
15
16 /**
17 * Determine if a given event has listeners.
18 *
19 * @param string $eventName
20 * @return bool
21 */
22 public function hasListeners($eventName);
23
24 /**
25 * Register an event subscriber with the dispatcher.
26 *
27 * @param object|string $subscriber
28 * @return void
29 */
30 public function subscribe($subscriber);
31
32 /**
33 * Dispatch an event until the first non-null response is returned.
34 *
35 * @param string|object $event
36 * @param mixed $payload
37 * @return array|null
38 */
39 public function until($event, $payload = []);
40
41 /**
42 * Dispatch an event and call the listeners.
43 *
44 * @param string|object $event
45 * @param mixed $payload
46 * @param bool $halt
47 * @return array|null
48 */
49 public function dispatch($event, $payload = [], $halt = false);
50
51 /**
52 * Register an event and payload to be fired later.
53 *
54 * @param string $event
55 * @param array $payload
56 * @return void
57 */
58 public function push($event, $payload = []);
59
60 /**
61 * Flush a set of pushed events.
62 *
63 * @param string $event
64 * @return void
65 */
66 public function flush($event);
67
68 /**
69 * Remove a set of listeners from the dispatcher.
70 *
71 * @param string $event
72 * @return void
73 */
74 public function forget($event);
75
76 /**
77 * Forget all of the queued listeners.
78 *
79 * @return void
80 */
81 public function forgetPushed();
82}