Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
LexemeHistoryAction | |
100.00% |
12 / 12 |
|
100.00% |
2 / 2 |
3 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
getPageTitle | |
100.00% |
8 / 8 |
|
100.00% |
1 / 1 |
2 |
1 | <?php |
2 | |
3 | declare( strict_types = 1 ); |
4 | |
5 | namespace Wikibase\Lexeme\MediaWiki\Actions; |
6 | |
7 | use Article; |
8 | use HistoryAction; |
9 | use MediaWiki\Context\IContextSource; |
10 | use Wikibase\Lexeme\DataAccess\Store\LemmaLookup; |
11 | use Wikibase\Lexeme\Domain\Model\LexemeId; |
12 | use Wikibase\Lexeme\Presentation\Formatters\LexemeTermFormatter; |
13 | use Wikibase\Lib\Store\EntityIdLookup; |
14 | |
15 | /** |
16 | * @license GPL-2.0-or-later |
17 | */ |
18 | class LexemeHistoryAction extends HistoryAction { |
19 | |
20 | private EntityIdLookup $entityIdLookup; |
21 | private LemmaLookup $lemmaLookup; |
22 | private LexemeTermFormatter $lexemeTermFormatter; |
23 | |
24 | public function __construct( |
25 | Article $article, |
26 | IContextSource $context, |
27 | EntityIdLookup $entityIdLookup, |
28 | LemmaLookup $lemmaLookup, |
29 | LexemeTermFormatter $lexemeTermFormatter |
30 | ) { |
31 | parent::__construct( $article, $context ); |
32 | |
33 | $this->entityIdLookup = $entityIdLookup; |
34 | $this->lemmaLookup = $lemmaLookup; |
35 | $this->lexemeTermFormatter = $lexemeTermFormatter; |
36 | } |
37 | |
38 | protected function getPageTitle() { |
39 | /** @var LexemeId $lexemeId */ |
40 | $lexemeId = $this->entityIdLookup->getEntityIdForTitle( $this->getTitle() ); |
41 | '@phan-var LexemeId $lexemeId'; |
42 | |
43 | if ( !$lexemeId ) { |
44 | return parent::getPageTitle(); |
45 | } |
46 | |
47 | $idSerialization = $lexemeId->getSerialization(); |
48 | $lemmaTerms = $this->lemmaLookup->getLemmas( $lexemeId ); |
49 | |
50 | $labelText = $this->lexemeTermFormatter->format( $lemmaTerms ); |
51 | |
52 | return $this->msg( 'wikibase-history-title-with-label' ) |
53 | ->plaintextParams( $idSerialization )->rawParams( $labelText ); |
54 | } |
55 | } |