wiki.techinc.nl/includes/language/FormatterFactory.php
daniel 3d55397207 Move creation of BlockErrorFormatter into FormatterFactory
The idea is that all formatters that need the user language or
other request specific context should be instantiated by
FormatterFactory.

Change-Id: I8334cc89dcf0f293298b82e004116be50a90f0d1
2024-01-26 13:03:44 -05:00

55 lines
1.4 KiB
PHP

<?php
namespace MediaWiki\Language;
use MediaWiki\Block\BlockErrorFormatter;
use MediaWiki\HookContainer\HookContainer;
use MediaWiki\Languages\LanguageFactory;
use MediaWiki\Status\StatusFormatter;
use MediaWiki\Title\TitleFormatter;
use MediaWiki\User\UserIdentityUtils;
use MessageCache;
use MessageLocalizer;
/**
* Factory for formatters of common complex objects
*
* @since 1.42
*/
class FormatterFactory {
private MessageCache $messageCache;
private TitleFormatter $titleFormatter;
private HookContainer $hookContainer;
private UserIdentityUtils $userIdentityUtils;
private LanguageFactory $languageFactory;
public function __construct(
MessageCache $messageCache,
TitleFormatter $titleFormatter,
HookContainer $hookContainer,
UserIdentityUtils $userIdentityUtils,
LanguageFactory $languageFactory
) {
$this->messageCache = $messageCache;
$this->titleFormatter = $titleFormatter;
$this->hookContainer = $hookContainer;
$this->userIdentityUtils = $userIdentityUtils;
$this->languageFactory = $languageFactory;
}
public function getStatusFormatter( MessageLocalizer $messageLocalizer ): StatusFormatter {
return new StatusFormatter( $messageLocalizer, $this->messageCache );
}
public function getBlockErrorFormatter( LocalizationContext $context ): BlockErrorFormatter {
return new BlockErrorFormatter(
$this->titleFormatter,
$this->hookContainer,
$this->userIdentityUtils,
$this->languageFactory,
$context
);
}
}