mwstake/mediawiki-component-events

2.0.1 2023-01-27 13:11 UTC

This package is auto-updated.

Last update: 2023-01-27 13:12:23 UTC


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 the require section of your composer.json file.

MediaWiki 1.39

  • Add "mwstake/mediawiki-component-events": "~2" to the require section of your composer.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 )