2023-09-25 13:32:24 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Language;
|
|
|
|
|
|
2023-10-01 12:03:37 +00:00
|
|
|
use MediaWiki\Block\BlockErrorFormatter;
|
|
|
|
|
use MediaWiki\HookContainer\HookContainer;
|
|
|
|
|
use MediaWiki\Languages\LanguageFactory;
|
2023-09-25 13:32:24 +00:00
|
|
|
use MediaWiki\Status\StatusFormatter;
|
2023-10-01 12:03:37 +00:00
|
|
|
use MediaWiki\Title\TitleFormatter;
|
|
|
|
|
use MediaWiki\User\UserIdentityUtils;
|
2023-09-25 13:32:24 +00:00
|
|
|
use MessageCache;
|
|
|
|
|
use MessageLocalizer;
|
2024-09-27 20:17:08 +00:00
|
|
|
use Psr\Log\LoggerInterface;
|
2023-09-25 13:32:24 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Factory for formatters of common complex objects
|
|
|
|
|
*
|
|
|
|
|
* @since 1.42
|
|
|
|
|
*/
|
|
|
|
|
class FormatterFactory {
|
|
|
|
|
|
|
|
|
|
private MessageCache $messageCache;
|
2023-10-01 12:03:37 +00:00
|
|
|
private TitleFormatter $titleFormatter;
|
|
|
|
|
private HookContainer $hookContainer;
|
|
|
|
|
private UserIdentityUtils $userIdentityUtils;
|
|
|
|
|
private LanguageFactory $languageFactory;
|
2024-09-27 20:17:08 +00:00
|
|
|
private LoggerInterface $logger;
|
2023-09-25 13:32:24 +00:00
|
|
|
|
2023-10-01 12:03:37 +00:00
|
|
|
public function __construct(
|
|
|
|
|
MessageCache $messageCache,
|
|
|
|
|
TitleFormatter $titleFormatter,
|
|
|
|
|
HookContainer $hookContainer,
|
|
|
|
|
UserIdentityUtils $userIdentityUtils,
|
2024-09-27 20:17:08 +00:00
|
|
|
LanguageFactory $languageFactory,
|
|
|
|
|
LoggerInterface $logger
|
2023-10-01 12:03:37 +00:00
|
|
|
) {
|
2023-09-25 13:32:24 +00:00
|
|
|
$this->messageCache = $messageCache;
|
2023-10-01 12:03:37 +00:00
|
|
|
$this->titleFormatter = $titleFormatter;
|
|
|
|
|
$this->hookContainer = $hookContainer;
|
|
|
|
|
$this->userIdentityUtils = $userIdentityUtils;
|
|
|
|
|
$this->languageFactory = $languageFactory;
|
2024-09-27 20:17:08 +00:00
|
|
|
$this->logger = $logger;
|
2023-09-25 13:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function getStatusFormatter( MessageLocalizer $messageLocalizer ): StatusFormatter {
|
2024-09-27 20:17:08 +00:00
|
|
|
return new StatusFormatter( $messageLocalizer, $this->messageCache, $this->logger );
|
2023-09-25 13:32:24 +00:00
|
|
|
}
|
|
|
|
|
|
2023-10-01 12:03:37 +00:00
|
|
|
public function getBlockErrorFormatter( LocalizationContext $context ): BlockErrorFormatter {
|
|
|
|
|
return new BlockErrorFormatter(
|
|
|
|
|
$this->titleFormatter,
|
|
|
|
|
$this->hookContainer,
|
|
|
|
|
$this->userIdentityUtils,
|
|
|
|
|
$this->languageFactory,
|
|
|
|
|
$context
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2023-09-25 13:32:24 +00:00
|
|
|
}
|