diff --git a/extension.json b/extension.json index 60248cf2..7a38f3c1 100644 --- a/extension.json +++ b/extension.json @@ -40,6 +40,7 @@ "class": "MediaWiki\\Extension\\ParserFunctions\\Hooks", "services": [ "MainConfig", + "HookContainer", "LanguageConverterFactory", "LanguageFactory", "LanguageNameUtils", diff --git a/includes/Hooks.php b/includes/Hooks.php index c455d85a..a1459dbd 100644 --- a/includes/Hooks.php +++ b/includes/Hooks.php @@ -4,6 +4,7 @@ namespace MediaWiki\Extension\ParserFunctions; use Config; use LinkCache; +use MediaWiki\HookContainer\HookContainer; use MediaWiki\Languages\LanguageConverterFactory; use MediaWiki\Languages\LanguageFactory; use MediaWiki\Languages\LanguageNameUtils; @@ -24,6 +25,7 @@ class Hooks implements /** * @param Config $config + * @param HookContainer $hookContainer * @param LanguageConverterFactory $languageConverterFactory * @param LanguageFactory $languageFactory * @param LanguageNameUtils $languageNameUtils @@ -33,6 +35,7 @@ class Hooks implements */ public function __construct( Config $config, + HookContainer $hookContainer, LanguageConverterFactory $languageConverterFactory, LanguageFactory $languageFactory, LanguageNameUtils $languageNameUtils, @@ -43,6 +46,7 @@ class Hooks implements $this->config = $config; $this->parserFunctions = new ParserFunctions( $config, + $hookContainer, $languageConverterFactory, $languageFactory, $languageNameUtils, diff --git a/includes/ParserFunctions.php b/includes/ParserFunctions.php index 9fa28cab..defc43bf 100644 --- a/includes/ParserFunctions.php +++ b/includes/ParserFunctions.php @@ -7,10 +7,10 @@ use DateTime; use DateTimeZone; use Exception; use LinkCache; +use MediaWiki\HookContainer\HookContainer; use MediaWiki\Languages\LanguageConverterFactory; use MediaWiki\Languages\LanguageFactory; use MediaWiki\Languages\LanguageNameUtils; -use MediaWiki\MediaWikiServices; use MediaWiki\SpecialPage\SpecialPageFactory; use MWTimestamp; use Parser; @@ -39,6 +39,9 @@ class ParserFunctions { /** @var Config */ private $config; + /** @var HookContainer */ + private $hookContainer; + /** @var LanguageConverterFactory */ private $languageConverterFactory; @@ -59,6 +62,7 @@ class ParserFunctions { /** * @param Config $config + * @param HookContainer $hookContainer * @param LanguageConverterFactory $languageConverterFactory * @param LanguageFactory $languageFactory * @param LanguageNameUtils $languageNameUtils @@ -68,6 +72,7 @@ class ParserFunctions { */ public function __construct( Config $config, + HookContainer $hookContainer, LanguageConverterFactory $languageConverterFactory, LanguageFactory $languageFactory, LanguageNameUtils $languageNameUtils, @@ -76,6 +81,7 @@ class ParserFunctions { SpecialPageFactory $specialPageFactory ) { $this->config = $config; + $this->hookContainer = $hookContainer; $this->languageConverterFactory = $languageConverterFactory; $this->languageFactory = $languageFactory; $this->languageNameUtils = $languageNameUtils; @@ -465,7 +471,7 @@ class ParserFunctions { private function timeCommon( Parser $parser, PPFrame $frame, $format, $date, $language, $local ) { - MediaWikiServices::getInstance()->getHookContainer()->register( + $this->hookContainer->register( 'ParserClearState', static function () { self::$mTimeChars = 0;