wfRunHooks( 'ConvertContent', array( $this, $toModel, $lossy, &$result ) );
return $result;
}
+
+ /**
+ * Returns a ParserOutput object, filled by a call to fillParserOutput().
+ * Subclasses that want to control the parser output may override this, or
+ * they can override fillParserOutput(). If they override getParserOutput(),
+ * itself, they should take care to call the ContentGetParserOutput hook.
+ *
+ * @param $title Title Context title for parsing
+ * @param $revId int|null Revision ID (for {{REVISIONID}})
+ * @param $options ParserOptions|null Parser options
+ * @param $generateHtml bool Whether or not to generate HTML
+ *
+ * @return ParserOutput representing the HTML form of the text
+ */
+ public function getParserOutput( Title $title, $revId = null,
+ ParserOptions $options = null, $generateHtml = true
+ ) {
+ # Generic implementation, relying on $this->getHtml()
+
+ if ( $options === null ) {
+ $options = $this->getContentHandler()->makeParserOptions( 'canonical' );
+ }
+
+ $po = new ParserOutput();
+
+ if ( wfRunHooks( 'ContentGetParserOutput',
+ array( $this, $title, $revId, $options, $generateHtml, &$po ) ) ) {
+
+ $this->fillParserOutput( $title, $revId, $options, $generateHtml, $po );
+ }
+
+ return $po;
+ }
+
+ /**
+ * Fills the provided ParserOutput object with the HTML returned by getHtml().
+ * Subclasses should override this (or getParserOutput) appropriately.
+ * This placeholder implementation always throws an exception.
+ *
+ * @param $title Title Context title for parsing
+ * @param $revId int|null Revision ID (for {{REVISIONID}})
+ * @param $options ParserOptions|null Parser options
+ * @param $generateHtml bool Whether or not to generate HTML
+ * @param &$output ParserOutput The output object to fill (reference).
+ *
+ * @throws MWException
+ */
+ protected function fillParserOutput( Title $title, $revId,
+ ParserOptions $options, $generateHtml, ParserOutput &$output
+ ) {
+ // Don't make abstract, so subclasses that override getParserOutput() directly don't fail.
+ throw new MWException( 'Subclasses of AbstractContent must override fillParserOutput!' );
+ }
}