MediaWiki master
RCFeed.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\RCFeed;
22
23use InvalidArgumentException;
25
31abstract class RCFeed {
35 public function __construct( array $params = [] ) {
36 }
37
45 abstract public function notify( RecentChange $rc, $actionComment = null );
46
47 final public static function factory( array $params ): RCFeed {
48 if ( !isset( $params['class'] ) ) {
49 if ( !isset( $params['uri'] ) ) {
50 throw new InvalidArgumentException( 'RCFeeds must have a class set' );
51 }
52 if ( strpos( $params['uri'], 'udp:' ) === 0 ) {
53 $params['class'] = UDPRCFeedEngine::class;
54 } elseif ( strpos( $params['uri'], 'redis:' ) === 0 ) {
55 $params['class'] = RedisPubSubFeedEngine::class;
56 } else {
57 global $wgRCEngines;
58 wfDeprecated( '$wgRCFeeds without class', '1.38' );
59 $scheme = parse_url( $params['uri'], PHP_URL_SCHEME );
60 if ( !$scheme ) {
61 throw new InvalidArgumentException( "Invalid RCFeed uri: {$params['uri']}" );
62 }
63 if ( !isset( $wgRCEngines[$scheme] ) ) {
64 throw new InvalidArgumentException( "Unknown RCFeed engine: $scheme" );
65 }
66 $params['class'] = $wgRCEngines[$scheme];
67 }
68 }
69
70 $class = $params['class'];
71 if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $class ) ) {
72 return $class;
73 }
74 if ( !class_exists( $class ) ) {
75 throw new InvalidArgumentException( "Unknown class '$class'." );
76 }
77 return new $class( $params );
78 }
79}
81class_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:81
__construct(array $params=[])
Definition RCFeed.php:35
notify(RecentChange $rc, $actionComment=null)
Dispatch the recent changes notification.
static factory(array $params)
Definition RCFeed.php:47
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.