MediaWiki master
RCFeed.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\RCFeed;
8
9use InvalidArgumentException;
11
17abstract class RCFeed {
21 public function __construct( array $params = [] ) {
22 }
23
31 abstract public function notify( RecentChange $rc, $actionComment = null );
32
33 final public static function factory( array $params ): RCFeed {
34 if ( !isset( $params['class'] ) ) {
35 if ( !isset( $params['uri'] ) ) {
36 throw new InvalidArgumentException( 'RCFeeds must have a class set' );
37 }
38 if ( str_starts_with( $params['uri'], 'udp:' ) ) {
39 $params['class'] = UDPRCFeedEngine::class;
40 } elseif ( str_starts_with( $params['uri'], 'redis:' ) ) {
41 $params['class'] = RedisPubSubFeedEngine::class;
42 } else {
43 global $wgRCEngines;
44 wfDeprecated( '$wgRCFeeds without class', '1.38' );
45 $scheme = parse_url( $params['uri'], PHP_URL_SCHEME );
46 if ( !$scheme ) {
47 throw new InvalidArgumentException( "Invalid RCFeed uri: {$params['uri']}" );
48 }
49 if ( !isset( $wgRCEngines[$scheme] ) ) {
50 throw new InvalidArgumentException( "Unknown RCFeed engine: $scheme" );
51 }
52 $params['class'] = $wgRCEngines[$scheme];
53 }
54 }
55
56 $class = $params['class'];
57 if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $class ) ) {
58 return $class;
59 }
60 if ( !class_exists( $class ) ) {
61 throw new InvalidArgumentException( "Unknown class '$class'." );
62 }
63 return new $class( $params );
64 }
65}
67class_alias( RCFeed::class, 'RCFeed' );
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:68
__construct(array $params=[])
Definition RCFeed.php:21
notify(RecentChange $rc, $actionComment=null)
Dispatch the recent changes notification.
static factory(array $params)
Definition RCFeed.php:33
Utility class for creating and reading rows in the recentchanges table.
$wgRCEngines
Config variable stub for the RCEngines setting, for use by phpdoc and IDEs.