Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
PageMoveLogger | |
0.00% |
0 / 18 |
|
0.00% |
0 / 3 |
12 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
logSuccess | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
2 | |||
logError | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | declare( strict_types = 1 ); |
3 | |
4 | namespace MediaWiki\Extension\Translate\MessageGroupProcessing; |
5 | |
6 | use ManualLogEntry; |
7 | use MediaWiki\Status\Status; |
8 | use MediaWiki\Title\Title; |
9 | use MediaWiki\User\User; |
10 | |
11 | /** |
12 | * Helper class for logging translatable bundle moves |
13 | * @author Abijeet Patro |
14 | * @author Niklas Laxström |
15 | * @since 2022.03 |
16 | * @license GPL-2.0-or-later |
17 | */ |
18 | class PageMoveLogger { |
19 | private string $logType; |
20 | private Title $baseSourceTitle; |
21 | |
22 | public function __construct( Title $baseSourceTitle, string $logType ) { |
23 | $this->baseSourceTitle = $baseSourceTitle; |
24 | $this->logType = $logType; |
25 | } |
26 | |
27 | public function logSuccess( User $performer, Title $target, string $reason ): void { |
28 | $entry = new ManualLogEntry( $this->logType, 'moveok' ); |
29 | $entry->setPerformer( $performer ); |
30 | $entry->setTarget( $this->baseSourceTitle ); |
31 | $entry->setComment( $reason ); |
32 | $entry->setParameters( [ 'target' => $target->getPrefixedText() ] ); |
33 | $logid = $entry->insert(); |
34 | $entry->publish( $logid ); |
35 | } |
36 | |
37 | public function logError( User $performer, Title $source, Title $target, Status $error ): void { |
38 | $entry = new ManualLogEntry( $this->logType, 'movenok' ); |
39 | $entry->setPerformer( $performer ); |
40 | $entry->setTarget( $source ); |
41 | $entry->setParameters( [ |
42 | 'target' => $target->getPrefixedText(), |
43 | 'error' => $error->getErrorsArray(), |
44 | ] ); |
45 | $logid = $entry->insert(); |
46 | $entry->publish( $logid ); |
47 | } |
48 | } |