Inject service HookContainer

Change-Id: I4a6292890c4cdad0d8e192e0c9fdc1c24abcd580
This commit is contained in:
Fomafix 2023-11-01 21:07:51 +00:00
parent 0e3cb3e009
commit d332bcbccd
3 changed files with 13 additions and 2 deletions

View file

@ -40,6 +40,7 @@
"class": "MediaWiki\\Extension\\ParserFunctions\\Hooks",
"services": [
"MainConfig",
"HookContainer",
"LanguageConverterFactory",
"LanguageFactory",
"LanguageNameUtils",

View file

@ -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,

View file

@ -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;