Page MenuHomeWickedGov Phorge

SuppressNotificationByTypeMiddleware.php
No OneTemporary

Size
828 B
Referenced Files
None
Subscribers
None

SuppressNotificationByTypeMiddleware.php

<?php
namespace MediaWiki\Notification\Middleware;
use MediaWiki\Notification\NotificationEnvelope;
/**
* An example Middleware that allows to remove notifications of specific types
*
* @since 1.45
*/
class SuppressNotificationByTypeMiddleware extends FilterMiddleware {
private string $notificationToSuppress;
/**
* Suppress sending specific notification
*/
public function __construct( string $notificationTypeToSuppress ) {
$this->notificationToSuppress = $notificationTypeToSuppress;
}
/**
* Decide whether we want to remove notification from the list
*/
protected function filter( NotificationEnvelope $envelope ): FilterMiddlewareAction {
return $envelope->getNotification()->getType() === $this->notificationToSuppress ?
FilterMiddlewareAction::REMOVE : FilterMiddlewareAction::KEEP;
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Nov 22, 05:02 (1 d, 6 m)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
a3/9f/aed2376e18af0079645aadf3745b
Default Alt Text
SuppressNotificationByTypeMiddleware.php (828 B)

Event Timeline