Allow more flexibility in RC feeds
authorKunal Mehta <legoktm@gmail.com>
Tue, 27 May 2014 00:50:11 +0000 (17:50 -0700)
committerKunal Mehta <legoktm@gmail.com>
Tue, 27 May 2014 02:27:54 +0000 (19:27 -0700)
The user can now specify which feeds to send to in
RecentChange::notifyFeeds if they don't want to use
$wgRCFeeds.

Additionally, the 'formatter' in $wgRCFeeds can now be an object
rather than just a class name.

Change-Id: Ibfdffc17a934e35223887c123331795563102752

includes/DefaultSettings.php
includes/changes/RecentChange.php

index 796e0c0..84a9e21 100644 (file)
@@ -5608,7 +5608,7 @@ $wgRC2UDPOmitBots = false;
  * The common options are:
  *   * 'uri' -- the address to which the notices are to be sent.
  *   * 'formatter' -- the class name (implementing RCFeedFormatter) which will
- *     produce the text to send.
+ *     produce the text to send. This can also be an object of the class.
  *   * 'omit_bots' -- whether the bot edits should be in the feed
  *   * 'omit_anon' -- whether anonymous edits should be in the feed
  *   * 'omit_user' -- whether edits by registered users should be in the feed
index 3a5a869..370e109 100644 (file)
@@ -390,13 +390,17 @@ class RecentChange {
 
        /**
         * Notify all the feeds about the change.
+        * @param array $feeds Optional feeds to send to, defaults to $wgRCFeeds
         */
-       public function notifyRCFeeds() {
+       public function notifyRCFeeds( array $feeds = null ) {
                global $wgRCFeeds;
+               if ( $feeds === null ) {
+                       $feeds = $wgRCFeeds;
+               }
 
                $performer = $this->getPerformer();
 
-               foreach ( $wgRCFeeds as $feed ) {
+               foreach ( $feeds as $feed ) {
                        $feed += array(
                                'omit_bots' => false,
                                'omit_anon' => false,
@@ -425,7 +429,7 @@ class RecentChange {
                        }
 
                        /** @var $formatter RCFeedFormatter */
-                       $formatter = new $feed['formatter']();
+                       $formatter = is_object( $feed['formatter'] ) ? $feed['formatter'] : new $feed['formatter']();
                        $line = $formatter->getLine( $feed, $this, $actionComment );
 
                        $engine->send( $feed, $line );