Move pdfhandler.messages module to extension.json

These messages have not changed since they were originally defined
in f4f87ceb (2015). Instead of using a hook to register the module
at runtime, put it in extension.json with a note next to the warning
configuration to keep the messages in sync.

Change-Id: I135bf1a9f2cd59926a40cc565e5c8a2a6f2483c0
This commit is contained in:
Kunal Mehta 2021-09-03 00:59:19 -07:00
parent 2e5afea2bc
commit 2328f802b1
2 changed files with 14 additions and 15 deletions

View file

@ -39,10 +39,15 @@
"i18n"
]
},
"Hooks": {
"ResourceLoaderRegisterModules": [
"MediaWiki\\Extension\\PdfHandler\\PdfHandler::registerWarningModule"
]
"ResourceModules": {
"pdfhandler.messages": {
"messages": [
"pdf-file-page-warning",
"pdf-file-page-warning-header",
"pdf-file-page-warning-info",
"pdf-file-page-warning-footer"
]
}
},
"MediaHandlers": {
"application/pdf": "MediaWiki\\Extension\\PdfHandler\\PdfHandler"

View file

@ -9,7 +9,6 @@ use MediaTransformError;
use MediaTransformOutput;
use MediaWiki\MediaWikiServices;
use PoolCounterWorkViaCallback;
use ResourceLoader;
use ThumbnailImage;
use TransformParameterError;
@ -36,6 +35,11 @@ use TransformParameterError;
*/
class PdfHandler extends ImageHandler {
/**
* Keep in sync with pdfhandler.messages in extension.json
*
* @see getWarningConfig
*/
private const MESSAGES = [
'main' => 'pdf-file-page-warning',
'header' => 'pdf-file-page-warning-header',
@ -447,16 +451,6 @@ class PdfHandler extends ImageHandler {
];
}
/**
* Register a module with the warning messages in it.
* @param ResourceLoader &$resourceLoader
*/
public static function registerWarningModule( &$resourceLoader ) {
$resourceLoader->register( 'pdfhandler.messages', [
'messages' => array_values( self::MESSAGES ),
] );
}
public function useSplitMetadata() {
return true;
}