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