11<?php
22/**
3- * Contains the class for replacing image normal image display with a modal.
3+ * Contains the class for replacing normal image display with a modal.
44 *
55 * @copyright (C) 2018, Tobias Oetterer, Paderborn University
66 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License, version 3 (or later)
2626
2727namespace MediaWiki \Extension \BootstrapComponents ;
2828
29- use DummyLinker ;
3029use File ;
3130use Html ;
3231use MediaTransformOutput ;
@@ -54,11 +53,6 @@ class ImageModal implements NestableInterface {
5453 */
5554 private BootstrapComponentsService $ bootstrapComponentService ;
5655
57- /**
58- * @var DummyLinker $dummyLinker
59- */
60- private DummyLinker $ dummyLinker ;
61-
6256 /**
6357 * @var File $file
6458 */
@@ -97,7 +91,7 @@ class ImageModal implements NestableInterface {
9791 /**
9892 * ImageModal constructor.
9993 *
100- * @param DummyLinker $dummyLinker
94+ * @param null $null (was DummyLinker $dummyLinker)
10195 * @param Title $title
10296 * @param File $file
10397 * @param NestingController $nestingController
@@ -107,12 +101,11 @@ class ImageModal implements NestableInterface {
107101 * @throws MWException cascading {@see ApplicationFactory} methods
108102 */
109103 public function __construct (
110- DummyLinker $ dummyLinker , Title $ title , File $ file ,
104+ $ null , Title $ title , File $ file ,
111105 NestingController $ nestingController , BootstrapComponentsService $ bootstrapComponentService ,
112106 ParserOutputHelper $ parserOutputHelper = null
113107 ) {
114108 $ this ->file = $ file ;
115- $ this ->dummyLinker = $ dummyLinker ;
116109 $ this ->title = $ title ;
117110
118111 $ this ->nestingController = $ nestingController ;
@@ -195,6 +188,7 @@ public function parse( array &$frameParams, array &$handlerParams, &$time, &$res
195188
196189 if ( $ res === '' ) {
197190 // ImageModal::turnParamsIntoModal returns the empty string, when something went wrong
191+ // returning true means, delegating the image rendering back to \MediaWiki\Linker\Linker::makeImageLink
198192 return true ;
199193 }
200194 return false ;
@@ -281,14 +275,6 @@ protected function getBootstrapComponentsService(): BootstrapComponentsService {
281275 return $ this ->bootstrapComponentService ;
282276 }
283277
284- /**
285- * @return DummyLinker
286- */
287- /** @scrutinizer ignore-unused */
288- protected function getDummyLinker (): DummyLinker {
289- return $ this ->dummyLinker ;
290- }
291-
292278 /**
293279 * @return File
294280 */
@@ -312,7 +298,6 @@ protected function getParentComponent(): bool|NestableInterface|null {
312298
313299 /**
314300 * @return ParserOutputHelper
315- * @deprecated
316301 */
317302 protected function getParserOutputHelper (): ParserOutputHelper {
318303 return $ this ->parserOutputHelper ;
@@ -422,16 +407,13 @@ private function assertImageModalNotSuppressed( array $frameParams ): bool
422407 ) {
423408 return false ;
424409 }
425- /** @see ParserOutputHelper::areImageModalsSuppressed as to why we need to use the global parser! */
426- $ parser = MediaWikiServices::getInstance ()->getParser ();
427- // the is_null test has to be added because otherwise some unit tests will fail
428- return is_null ( $ parser ->getOutput () )
429- || !$ parser ->getOutput ()->getExtensionData ( BootstrapComponents::EXTENSION_DATA_NO_IMAGE_MODAL );
410+ return !MediaWikiServices::getInstance ()->getService ( 'BootstrapComponentsService ' )
411+ ->areModalsSuppressedByMagicWord ();
430412 }
431413
432414 /**
433415 * @param MediaTransformOutput $img
434- * @param array $sanitizedFrameParams
416+ * @param array $sanitizedFrameParams
435417 *
436418 * @return string
437419 */
0 commit comments