aboutsummaryrefslogtreecommitdiffstats
path: root/includes/language/FormatterFactory.php
blob: bf92fffb0e7b3a33c4b2928b142eca2f77d6b1f9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?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 MessageLocalizer;
use Psr\Log\LoggerInterface;

/**
 * Factory for formatters of common complex objects
 *
 * @since 1.42
 */
class FormatterFactory {

	private MessageParser $messageParser;
	private TitleFormatter $titleFormatter;
	private HookContainer $hookContainer;
	private UserIdentityUtils $userIdentityUtils;
	private LanguageFactory $languageFactory;
	private LoggerInterface $logger;

	public function __construct(
		MessageParser $messageParser,
		TitleFormatter $titleFormatter,
		HookContainer $hookContainer,
		UserIdentityUtils $userIdentityUtils,
		LanguageFactory $languageFactory,
		LoggerInterface $logger
	) {
		$this->messageParser = $messageParser;
		$this->titleFormatter = $titleFormatter;
		$this->hookContainer = $hookContainer;
		$this->userIdentityUtils = $userIdentityUtils;
		$this->languageFactory = $languageFactory;
		$this->logger = $logger;
	}

	public function getStatusFormatter( MessageLocalizer $messageLocalizer ): StatusFormatter {
		return new StatusFormatter( $messageLocalizer, $this->messageParser, $this->logger );
	}

	public function getBlockErrorFormatter( LocalizationContext $context ): BlockErrorFormatter {
		return new BlockErrorFormatter(
			$this->titleFormatter,
			$this->hookContainer,
			$this->userIdentityUtils,
			$this->languageFactory,
			$context
		);
	}

}