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" "i18n"
] ]
}, },
"Hooks": { "ResourceModules": {
"ResourceLoaderRegisterModules": [ "pdfhandler.messages": {
"MediaWiki\\Extension\\PdfHandler\\PdfHandler::registerWarningModule" "messages": [
"pdf-file-page-warning",
"pdf-file-page-warning-header",
"pdf-file-page-warning-info",
"pdf-file-page-warning-footer"
] ]
}
}, },
"MediaHandlers": { "MediaHandlers": {
"application/pdf": "MediaWiki\\Extension\\PdfHandler\\PdfHandler" "application/pdf": "MediaWiki\\Extension\\PdfHandler\\PdfHandler"

View file

@ -9,7 +9,6 @@ use MediaTransformError;
use MediaTransformOutput; use MediaTransformOutput;
use MediaWiki\MediaWikiServices; use MediaWiki\MediaWikiServices;
use PoolCounterWorkViaCallback; use PoolCounterWorkViaCallback;
use ResourceLoader;
use ThumbnailImage; use ThumbnailImage;
use TransformParameterError; use TransformParameterError;
@ -36,6 +35,11 @@ use TransformParameterError;
*/ */
class PdfHandler extends ImageHandler { class PdfHandler extends ImageHandler {
/**
* Keep in sync with pdfhandler.messages in extension.json
*
* @see getWarningConfig
*/
private const MESSAGES = [ private const MESSAGES = [
'main' => 'pdf-file-page-warning', 'main' => 'pdf-file-page-warning',
'header' => 'pdf-file-page-warning-header', '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() { public function useSplitMetadata() {
return true; return true;
} }