1 | <?php |
||
12 | class EventManager |
||
13 | { |
||
14 | /** @var array */ |
||
15 | private static $dispatchers = []; |
||
16 | |||
17 | /** |
||
18 | * Gets the event dispatcher. |
||
19 | */ |
||
20 | public static function getDispatcher(string $class): EventDispatcher |
||
28 | |||
29 | /** |
||
30 | * Resets the event dispatcher for a given class. |
||
31 | */ |
||
32 | public static function reset(string $class): void |
||
38 | |||
39 | /** |
||
40 | * Subscribes to a listener to an event. |
||
41 | * |
||
42 | * @param string $event event name |
||
43 | * @param int $priority optional priority, higher #s get called first |
||
44 | */ |
||
45 | public static function listen(string $class, string $event, callable $listener, int $priority = 0): void |
||
49 | |||
50 | /** |
||
51 | * Dispatches the given event and checks if it was successful. |
||
52 | * If it fails then any active transaction will be rolled back |
||
53 | * on the model. |
||
54 | * |
||
55 | * @return bool true if the events were successfully propagated |
||
56 | */ |
||
57 | public static function dispatch(Model $model, AbstractEvent $event, bool $usesTransactions): bool |
||
80 | } |
||
81 |