1 | <?php |
||
25 | trait Dispatcher |
||
26 | { |
||
27 | /** |
||
28 | * @var array |
||
29 | */ |
||
30 | private $listeners = []; |
||
31 | |||
32 | /** |
||
33 | * Dispatch an event |
||
34 | * |
||
35 | * @param Event|string $event The event or the name |
||
36 | * |
||
37 | * @return $this |
||
38 | */ |
||
39 | public function trigger($event) |
||
55 | |||
56 | /** |
||
57 | * Register an event handler |
||
58 | * |
||
59 | * @param string $event The event name |
||
60 | * @param callable $callback The callback to call |
||
61 | * |
||
62 | * @return $this |
||
63 | */ |
||
64 | public function on($event, $callback) |
||
72 | } |
||
73 | |||
75 |