mwstake / mediawiki-component-events
Mechanism for firing events
2.0.1
2023-01-27 13:11 UTC
Requires
- composer/installers: ~1.0|~2
- mwstake/mediawiki-componentloader: ~1
Requires (Dev)
- jakub-onderka/php-console-highlighter: 0.4.0
- jakub-onderka/php-parallel-lint: 1.0.0
- mediawiki/mediawiki-codesniffer: 29.0.0
- mediawiki/minus-x: 1.0.0
- phpunit/phpunit: ^8.5
README
This component allows you to emit notification events to consumers
Use in a MediaWiki extension
MediaWiki 1.35
- Add
"mwstake/mediawiki-component-events": "~1"
to therequire
section of yourcomposer.json
file.
MediaWiki 1.39
- Add
"mwstake/mediawiki-component-events": "~2"
to therequire
section of yourcomposer.json
file.
Register consumer
$GLOBALS['wgMWStakeNotificationEventConsumers'][] = [ 'class' => MyConsumer::class, 'services' => [ 'UserFactory' ] ];
Create Event
class MyEvent implements \MWStake\MediaWiki\Component\Events\INotificationEvent { .... } $event = new MyEvent( $user );
Emit Event
$notifier = MediaWikiServices::getInstance()->getService( 'MWStake.Notifier' ); $notifier->emit( $event ); // Will call MyConsumer::consume( $event )