Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
14 / 14 |
|
100.00% |
3 / 3 |
CRAP | |
100.00% |
1 / 1 |
FormatterFactory | |
100.00% |
14 / 14 |
|
100.00% |
3 / 3 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
1 | |||
getStatusFormatter | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getBlockErrorFormatter | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Language; |
4 | |
5 | use MediaWiki\Block\BlockErrorFormatter; |
6 | use MediaWiki\HookContainer\HookContainer; |
7 | use MediaWiki\Languages\LanguageFactory; |
8 | use MediaWiki\Status\StatusFormatter; |
9 | use MediaWiki\Title\TitleFormatter; |
10 | use MediaWiki\User\UserIdentityUtils; |
11 | use MessageLocalizer; |
12 | use Psr\Log\LoggerInterface; |
13 | |
14 | /** |
15 | * Factory for formatters of common complex objects |
16 | * |
17 | * @since 1.42 |
18 | */ |
19 | class FormatterFactory { |
20 | |
21 | private MessageParser $messageParser; |
22 | private TitleFormatter $titleFormatter; |
23 | private HookContainer $hookContainer; |
24 | private UserIdentityUtils $userIdentityUtils; |
25 | private LanguageFactory $languageFactory; |
26 | private LoggerInterface $logger; |
27 | |
28 | public function __construct( |
29 | MessageParser $messageParser, |
30 | TitleFormatter $titleFormatter, |
31 | HookContainer $hookContainer, |
32 | UserIdentityUtils $userIdentityUtils, |
33 | LanguageFactory $languageFactory, |
34 | LoggerInterface $logger |
35 | ) { |
36 | $this->messageParser = $messageParser; |
37 | $this->titleFormatter = $titleFormatter; |
38 | $this->hookContainer = $hookContainer; |
39 | $this->userIdentityUtils = $userIdentityUtils; |
40 | $this->languageFactory = $languageFactory; |
41 | $this->logger = $logger; |
42 | } |
43 | |
44 | public function getStatusFormatter( MessageLocalizer $messageLocalizer ): StatusFormatter { |
45 | return new StatusFormatter( $messageLocalizer, $this->messageParser, $this->logger ); |
46 | } |
47 | |
48 | public function getBlockErrorFormatter( LocalizationContext $context ): BlockErrorFormatter { |
49 | return new BlockErrorFormatter( |
50 | $this->titleFormatter, |
51 | $this->hookContainer, |
52 | $this->userIdentityUtils, |
53 | $this->languageFactory, |
54 | $context |
55 | ); |
56 | } |
57 | |
58 | } |