Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
LexemeFieldDefinitions | |
100.00% |
10 / 10 |
|
100.00% |
2 / 2 |
2 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 | |||
getFields | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\Search\Elastic; |
4 | |
5 | use Wikibase\DataModel\Entity\NumericPropertyId; |
6 | use Wikibase\DataModel\Services\Lookup\EntityLookup; |
7 | use Wikibase\Repo\Search\Fields\FieldDefinitions; |
8 | use Wikibase\Repo\Search\Fields\WikibaseIndexField; |
9 | |
10 | /** |
11 | * @license GPL-2.0-or-later |
12 | * @author Katie Filbert < aude.wiki@gmail.com > |
13 | */ |
14 | class LexemeFieldDefinitions implements FieldDefinitions { |
15 | |
16 | /** |
17 | * @var EntityLookup |
18 | */ |
19 | private $entityLookup; |
20 | |
21 | /** |
22 | * @var NumericPropertyId|null |
23 | */ |
24 | private $lexemeLanguageCodePropertyId; |
25 | /** |
26 | * @var FieldDefinitions |
27 | */ |
28 | private $statements; |
29 | |
30 | public function __construct( FieldDefinitions $statements, |
31 | EntityLookup $entityLookup, |
32 | NumericPropertyId $lexemeLanguageCodePropertyId = null ) { |
33 | $this->statements = $statements; |
34 | $this->lexemeLanguageCodePropertyId = $lexemeLanguageCodePropertyId; |
35 | $this->entityLookup = $entityLookup; |
36 | } |
37 | |
38 | /** |
39 | * @return WikibaseIndexField[] |
40 | */ |
41 | public function getFields() { |
42 | $fields = $this->statements->getFields(); |
43 | |
44 | $fields[LemmaField::NAME] = new LemmaField(); |
45 | $fields[FormsField::NAME] = new FormsField(); |
46 | $fields[LexemeLanguageField::NAME] = new LexemeLanguageField( $this->entityLookup, |
47 | $this->lexemeLanguageCodePropertyId ); |
48 | $fields[LexemeCategoryField::NAME] = new LexemeCategoryField(); |
49 | return $fields; |
50 | } |
51 | |
52 | } |