Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
LexemeParserOutputUpdater | |
0.00% |
0 / 12 |
|
0.00% |
0 / 3 |
90 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
updateParserOutput | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
6 | |||
updateParserOutputForLexeme | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
42 |
1 | <?php |
2 | |
3 | namespace Wikibase\Lexeme\MediaWiki\ParserOutput; |
4 | |
5 | use MediaWiki\Parser\ParserOutput; |
6 | use Wikibase\DataModel\Entity\EntityDocument; |
7 | use Wikibase\Lexeme\Domain\Model\Lexeme; |
8 | use Wikibase\Repo\ParserOutput\EntityParserOutputUpdater; |
9 | use Wikibase\Repo\ParserOutput\StatementDataUpdater; |
10 | |
11 | /** |
12 | * @license GPL-2.0-or-later |
13 | */ |
14 | class LexemeParserOutputUpdater implements EntityParserOutputUpdater { |
15 | |
16 | private StatementDataUpdater $statementDataUpdater; |
17 | |
18 | public function __construct( StatementDataUpdater $statementDataUpdater ) { |
19 | $this->statementDataUpdater = $statementDataUpdater; |
20 | } |
21 | |
22 | public function updateParserOutput( ParserOutput $parserOutput, EntityDocument $entity ) { |
23 | if ( $entity instanceof Lexeme ) { |
24 | $this->updateParserOutputForLexeme( $parserOutput, $entity ); |
25 | } |
26 | } |
27 | |
28 | public function updateParserOutputForLexeme( ParserOutput $parserOutput, Lexeme $lexeme ) { |
29 | foreach ( $lexeme->getStatements() as $statement ) { |
30 | $this->statementDataUpdater->processStatement( $statement ); |
31 | } |
32 | |
33 | foreach ( $lexeme->getForms()->toArray() as $form ) { |
34 | foreach ( $form->getStatements() as $statement ) { |
35 | $this->statementDataUpdater->processStatement( $statement ); |
36 | } |
37 | } |
38 | |
39 | foreach ( $lexeme->getSenses()->toArray() as $sense ) { |
40 | foreach ( $sense->getStatements() as $statement ) { |
41 | $this->statementDataUpdater->processStatement( $statement ); |
42 | } |
43 | } |
44 | |
45 | $this->statementDataUpdater->updateParserOutput( $parserOutput ); |
46 | } |
47 | |
48 | } |