3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
22 * Base class for RC feed engines that send messages in a freely configurable
23 * format to a uri-addressed engine set in $wgRCEngines.
26 abstract class FormattedRCFeed
extends RCFeed
{
30 * @param array $params
35 public function __construct( array $params = [] ) {
36 $this->params
= $params;
40 * Send some text to the specified feed.
42 * @param array $feed The feed, as configured in an associative array
43 * @param string $line The text to send
44 * @return bool Success
46 abstract public function send( array $feed, $line );
49 * @param RecentChange $rc
50 * @param string|null $actionComment
51 * @return bool Success
53 public function notify( RecentChange
$rc, $actionComment = null ) {
54 $params = $this->params
;
55 /** @var $formatter RCFeedFormatter */
56 $formatter = is_object( $params['formatter'] ) ?
$params['formatter'] : new $params['formatter'];
58 $line = $formatter->getLine( $params, $rc, $actionComment );
60 // @codeCoverageIgnoreStart
61 // T109544 - If a feed formatter returns null, this will otherwise cause an
62 // error in at least RedisPubSubFeedEngine. Not sure best to handle this.
64 // @codeCoverageIgnoreEnd
66 return $this->send( $params, $line );