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 throw new InvalidArgumentException( 'RCFeeds must have a class set' );
36 }
37 if ( isset( $params['uri'] ) ) {
38 $scheme = parse_url( $params['uri'], PHP_URL_SCHEME );
39 if ( !$scheme ) {
40 throw new InvalidArgumentException( "Invalid RCFeed uri: {$params['uri']}" );
41 }
42 }
43
44 $class = $params['class'];
45
46 if ( defined( 'MW_PHPUNIT_TEST' ) && is_object( $class ) ) {
47 return $class;
48 }
49 if ( !class_exists( $class ) ) {
50 throw new InvalidArgumentException( "Unknown class '$class'." );
51 }
52 return new $class( $params );
53 }
54}
56class_alias( RCFeed::class, 'RCFeed' );
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:69
__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.