Wikibase
MediaWiki Wikibase extension
Wikibase\Repo\GenericEventDispatcher Class Reference

Dispatches a notification to a set of watchers. More...

+ Inheritance diagram for Wikibase\Repo\GenericEventDispatcher:

Public Member Functions

 __construct ( $interface)
 
 registerWatcher ( $listener)
 Registers a watcher. More...
 
 unregisterWatcher ( $key)
 Unregisters a watcher using its registration key. More...
 
 dispatch ( $event,... $args)
 Dispatches a notification to all registered watchers. More...
 

Private Attributes

 $watchers = []
 
 $key = 0
 
 $interface
 

Detailed Description

Dispatches a notification to a set of watchers.

Todo:
should go into MediaWiki core.
Author
Daniel Kinzler

Constructor & Destructor Documentation

◆ __construct()

Wikibase\Repo\GenericEventDispatcher::__construct (   $interface)
Parameters
string$interfacethe interface watchers must implement

Member Function Documentation

◆ dispatch()

Wikibase\Repo\GenericEventDispatcher::dispatch (   $event,
  $args 
)

Dispatches a notification to all registered watchers.

Parameters
string$eventthe name of the event, that is, the name of the method to call on the watchers.
mixed...$args Any extra parameters are passed to the watcher method.
Exceptions
InvalidArgumentException

◆ registerWatcher()

Wikibase\Repo\GenericEventDispatcher::registerWatcher (   $listener)

Registers a watcher.

The watcher will be called whenever the dispatch() method is called, until the watcher is unregistered.

Parameters
object$listener
Exceptions
InvalidArgumentException
Returns
mixed The listener key, for removing the listener later.

◆ unregisterWatcher()

Wikibase\Repo\GenericEventDispatcher::unregisterWatcher (   $key)

Unregisters a watcher using its registration key.

The watcher will no longer be called by dispatch().

Parameters
mixed$keyA watcher key as returned by registerWatcher().
Exceptions
InvalidArgumentException

Member Data Documentation

◆ $interface

Wikibase\Repo\GenericEventDispatcher::$interface
private

◆ $key

Wikibase\Repo\GenericEventDispatcher::$key = 0
private

◆ $watchers

Wikibase\Repo\GenericEventDispatcher::$watchers = []
private

The documentation for this class was generated from the following file: