X-Git-Url: https://scripts.mit.edu/gitweb/autoinstallsdev/mediawiki.git/blobdiff_plain/19e297c21b10b1b8a3acad5e73fc71dcb35db44a..6932310fd58ebef145fa01eb76edf7150284d8ea:/includes/rcfeed/FormattedRCFeed.php diff --git a/includes/rcfeed/FormattedRCFeed.php b/includes/rcfeed/FormattedRCFeed.php new file mode 100644 index 00000000..afe900d0 --- /dev/null +++ b/includes/rcfeed/FormattedRCFeed.php @@ -0,0 +1,68 @@ +params = $params; + } + + /** + * Send some text to the specified feed. + * + * @param array $feed The feed, as configured in an associative array + * @param string $line The text to send + * @return bool Success + */ + abstract public function send( array $feed, $line ); + + /** + * @param RecentChange $rc + * @param string|null $actionComment + * @return bool Success + */ + public function notify( RecentChange $rc, $actionComment = null ) { + $params = $this->params; + /** @var RCFeedFormatter $formatter */ + $formatter = is_object( $params['formatter'] ) ? $params['formatter'] : new $params['formatter']; + + $line = $formatter->getLine( $params, $rc, $actionComment ); + if ( !$line ) { + // @codeCoverageIgnoreStart + // T109544 - If a feed formatter returns null, this will otherwise cause an + // error in at least RedisPubSubFeedEngine. Not sure best to handle this. + return; + // @codeCoverageIgnoreEnd + } + return $this->send( $params, $line ); + } +}