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