Page MenuHomeWickedGov Phorge

FilterMiddleware.php
No OneTemporary

Size
967 B
Referenced Files
None
Subscribers
None

FilterMiddleware.php

<?php
namespace MediaWiki\Notification\Middleware;
use MediaWiki\Notification\NotificationEnvelope;
use MediaWiki\Notification\NotificationMiddlewareInterface;
use MediaWiki\Notification\NotificationsBatch;
/**
* Middleware that allows to filter notifications
*
* @since 1.44
* @unstable
*/
abstract class FilterMiddleware implements NotificationMiddlewareInterface {
protected const KEEP = true;
protected const REMOVE = false;
/**
* Decide whether we want to remove notification from the list
*
* Return self::KEEP or true to keep the envelope
* Return self::REMOVE or false to remove the envelope
*/
abstract protected function filter( NotificationEnvelope $envelope ): bool;
/**
* @param NotificationsBatch $batch
* @param callable():void $next
*/
public function handle( NotificationsBatch $batch, callable $next ): void {
$next();
$batch->filter( fn ( NotificationEnvelope $envelope ) => $this->filter( $envelope ) );
}
}

File Metadata

Mime Type
text/x-php
Expires
Sun, Nov 22, 05:50 (5 d, 20 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
c6/4e/a6d26c8702d6dabc163605149215
Default Alt Text
FilterMiddleware.php (967 B)

Event Timeline