mwstake / mediawiki-component-events
Mechanism for firing events
Installs: 9 402
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 4
Forks: 1
Open Issues: 0
Requires
- composer/installers: ~1.0|~2
- mwstake/mediawiki-componentloader: ~1
Requires (Dev)
- mediawiki/mediawiki-codesniffer: 41.0.0
- mediawiki/minus-x: 1.1.1
- php-parallel-lint/php-console-highlighter: 1.0.0
- php-parallel-lint/php-parallel-lint: 1.3.2
- 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 )