Merge "Override ContentHandler::fillParserOutput instead of Content::fillParserOutput."

This commit is contained in:
jenkins-bot 2021-10-08 14:32:36 +00:00 committed by Gerrit Code Review
commit 669b351241
2 changed files with 22 additions and 24 deletions

View file

@ -43,30 +43,6 @@ class GadgetDefinitionContent extends JsonContent {
return FormatJson::encode( $this->getAssocArray(), "\t", FormatJson::UTF8_OK );
}
/**
* Register some links
*
* @param Title $title
* @param int $revId
* @param ParserOptions $options
* @param bool $generateHtml
* @param ParserOutput &$output
*/
protected function fillParserOutput( Title $title, $revId,
ParserOptions $options, $generateHtml, ParserOutput &$output
) {
parent::fillParserOutput( $title, $revId, $options, $generateHtml, $output );
$assoc = $this->getAssocArray();
foreach ( [ 'scripts', 'styles' ] as $type ) {
foreach ( $assoc['module'][$type] as $page ) {
$title = Title::makeTitleSafe( NS_GADGET, $page );
if ( $title ) {
$output->addLink( $title );
}
}
}
}
/**
* @return Status
*/

View file

@ -21,6 +21,7 @@
* @file
*/
use MediaWiki\Content\Renderer\ContentParseParams;
use MediaWiki\Revision\SlotRenderingProvider;
class GadgetDefinitionContentHandler extends JsonContentHandler {
@ -101,4 +102,25 @@ class GadgetDefinitionContentHandler extends JsonContentHandler {
[ new GadgetDefinitionSecondaryDataUpdate( $title ) ]
);
}
/**
* @inheritDoc
*/
protected function fillParserOutput(
Content $content,
ContentParseParams $cpoParams,
ParserOutput &$output
) {
'@phan-var GadgetDefinitionContent $content';
parent::fillParserOutput( $content, $cpoParams, $output );
$assoc = $content->getAssocArray();
foreach ( [ 'scripts', 'styles' ] as $type ) {
foreach ( $assoc['module'][$type] as $page ) {
$title = Title::makeTitleSafe( NS_GADGET, $page );
if ( $title ) {
$output->addLink( $title );
}
}
}
}
}