Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | n/a |
0 / 0 |
n/a |
0 / 0 |
CRAP | n/a |
0 / 0 |
1 | <?php |
2 | namespace MediaWiki\DomainEvent; |
3 | |
4 | /** |
5 | * Service object for registering listeners for domain events. |
6 | * |
7 | * @since 1.44 |
8 | * @unstable until 1.45 |
9 | */ |
10 | interface DomainEventSource { |
11 | |
12 | /** |
13 | * Add a listener that will be notified on events of the given type, |
14 | * triggered by changed to the persistent state of the local wiki. |
15 | * |
16 | * Listeners should be implemented to be idempotent, that is, calling |
17 | * them multiple times with the same parameters should produce the same |
18 | * outcome. |
19 | * |
20 | * Listeners will be invoked after the transaction that produced the event |
21 | * was committed successfully. Delivery guarantees depend on the |
22 | * implementation of DomainEvent sink used. |
23 | * |
24 | * @param string $eventType |
25 | * @param callable $listener |
26 | */ |
27 | public function registerListener( string $eventType, $listener ): void; |
28 | |
29 | /** |
30 | * Register the given subscriber to this event source. A subscriber |
31 | * is a way to bundle related listeners, typically by implementing them |
32 | * as methods on the subscriber object. |
33 | * |
34 | * If the subscriber is supplied as a spec array, instantiation and |
35 | * application may be deferred until one of the relevant events is |
36 | * triggered. |
37 | * |
38 | * @param DomainEventSubscriber|array $subscriber |
39 | * - object: a DomainEventSubscriber |
40 | * - array: An object spec suitable for use with ObjectFactory. |
41 | * The array must use the key 'events' to specify which |
42 | * events will trigger application of the subscriber. |
43 | */ |
44 | public function registerSubscriber( $subscriber ): void; |
45 | |
46 | } |