MediaWiki REL1_39
RCFeed.php
Go to the documentation of this file.
1<?php
25abstract class RCFeed {
29 public function __construct( array $params = [] ) {
30 }
31
39 abstract public function notify( RecentChange $rc, $actionComment = null );
40
45 final public static function factory( array $params ): RCFeed {
46 if ( !isset( $params['class'] ) ) {
47 if ( !isset( $params['uri'] ) ) {
48 throw new InvalidArgumentException( 'RCFeeds must have a class set' );
49 }
50 if ( strpos( $params['uri'], 'udp:' ) === 0 ) {
51 $params['class'] = UDPRCFeedEngine::class;
52 } elseif ( strpos( $params['uri'], 'redis:' ) === 0 ) {
53 $params['class'] = RedisPubSubFeedEngine::class;
54 } else {
55 global $wgRCEngines;
56 wfDeprecated( '$wgRCFeeds without class', '1.38' );
57 $scheme = parse_url( $params['uri'], PHP_URL_SCHEME );
58 if ( !$scheme ) {
59 throw new InvalidArgumentException( "Invalid RCFeed uri: {$params['uri']}" );
60 }
61 if ( !isset( $wgRCEngines[$scheme] ) ) {
62 throw new InvalidArgumentException( "Unknown RCFeed engine: $scheme" );
63 }
64 $params['class'] = $wgRCEngines[$scheme];
65 }
66 }
67
68 $class = $params['class'];
69 if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $class ) ) {
70 return $class;
71 }
72 if ( !class_exists( $class ) ) {
73 throw new InvalidArgumentException( "Unknown class '$class'." );
74 }
75 return new $class( $params );
76 }
77}
wfDeprecated( $function, $version=false, $component=false, $callerOffset=2)
Logs a warning that a deprecated feature was used.
if(!defined('MW_SETUP_CALLBACK'))
The persistent session ID (if any) loaded at startup.
Definition WebStart.php:82
__construct(array $params=[])
Definition RCFeed.php:29
static factory(array $params)
Definition RCFeed.php:45
notify(RecentChange $rc, $actionComment=null)
Dispatch the recent changes notification.
Utility class for creating new RC entries.
$wgRCEngines
Config variable stub for the RCEngines setting, for use by phpdoc and IDEs.