From 2328f802b13d783d870ac597a0971f0016083b27 Mon Sep 17 00:00:00 2001 From: Kunal Mehta Date: Fri, 3 Sep 2021 00:59:19 -0700 Subject: [PATCH] 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 --- extension.json | 13 +++++++++---- includes/PdfHandler.php | 16 +++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/extension.json b/extension.json index ea4ce6b..39d93f3 100644 --- a/extension.json +++ b/extension.json @@ -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" diff --git a/includes/PdfHandler.php b/includes/PdfHandler.php index 886f66a..010e833 100644 --- a/includes/PdfHandler.php +++ b/includes/PdfHandler.php @@ -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; }