|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WikibaseQuality\ConstraintReport\ConstraintCheck\Message; |
|
6
|
|
|
|
|
7
|
|
|
use Config; |
|
8
|
|
|
use Language; |
|
9
|
|
|
use MessageLocalizer; |
|
10
|
|
|
use ValueFormatters\FormatterOptions; |
|
11
|
|
|
use Wikibase\Lib\Formatters\OutputFormatValueFormatterFactory; |
|
12
|
|
|
use Wikibase\Lib\Formatters\SnakFormatter; |
|
13
|
|
|
use Wikibase\View\EntityIdFormatterFactory; |
|
14
|
|
|
|
|
15
|
|
|
/** |
|
16
|
|
|
* @license GPL-2.0-or-later |
|
17
|
|
|
*/ |
|
18
|
|
|
class ViolationMessageRendererFactory { |
|
19
|
|
|
|
|
20
|
|
|
/** @var Config */ |
|
21
|
|
|
private $config; |
|
22
|
|
|
|
|
23
|
|
|
/** @var MessageLocalizer */ |
|
24
|
|
|
private $messageLocalizer; |
|
25
|
|
|
|
|
26
|
|
|
/** @var EntityIdFormatterFactory */ |
|
27
|
|
|
private $entityIdHtmlLinkFormatterFactory; |
|
28
|
|
|
|
|
29
|
|
|
/** @var OutputFormatValueFormatterFactory */ |
|
30
|
|
|
private $valueFormatterFactory; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct( |
|
33
|
|
|
Config $config, |
|
34
|
|
|
MessageLocalizer $messageLocalizer, |
|
35
|
|
|
EntityIdFormatterFactory $entityIdHtmlLinkFormatterFactory, |
|
36
|
|
|
OutputFormatValueFormatterFactory $valueFormatterFactory |
|
37
|
|
|
) { |
|
38
|
|
|
$this->config = $config; |
|
39
|
|
|
$this->messageLocalizer = $messageLocalizer; |
|
40
|
|
|
$this->entityIdHtmlLinkFormatterFactory = $entityIdHtmlLinkFormatterFactory; |
|
41
|
|
|
$this->valueFormatterFactory = $valueFormatterFactory; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
public function getViolationMessageRenderer( Language $language ): ViolationMessageRenderer { |
|
45
|
|
|
$formatterOptions = new FormatterOptions(); |
|
46
|
|
|
$formatterOptions->setOption( SnakFormatter::OPT_LANG, $language->getCode() ); |
|
47
|
|
|
return new MultilingualTextViolationMessageRenderer( |
|
48
|
|
|
$this->entityIdHtmlLinkFormatterFactory |
|
49
|
|
|
->getEntityIdFormatter( $language ), |
|
50
|
|
|
$this->valueFormatterFactory |
|
51
|
|
|
->getValueFormatter( SnakFormatter::FORMAT_HTML, $formatterOptions ), |
|
52
|
|
|
$this->messageLocalizer, |
|
53
|
|
|
$this->config |
|
54
|
|
|
); |
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
} |
|
58
|
|
|
|