Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 37 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
MentorChangeLogFormatter | |
0.00% |
0 / 37 |
|
0.00% |
0 / 4 |
210 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
extractParameters | |
0.00% |
0 / 14 |
|
0.00% |
0 / 1 |
30 | |||
getMessageParameters | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
2 | |||
getPreloadTitles | |
0.00% |
0 / 18 |
|
0.00% |
0 / 1 |
56 |
1 | <?php |
2 | |
3 | namespace GrowthExperiments\Mentorship; |
4 | |
5 | use LogEntry; |
6 | use LogFormatter; |
7 | use MediaWiki\Title\TitleParser; |
8 | |
9 | class MentorChangeLogFormatter extends LogFormatter { |
10 | private TitleParser $titleParser; |
11 | |
12 | public function __construct( |
13 | LogEntry $entry, |
14 | TitleParser $titleParser |
15 | ) { |
16 | parent::__construct( $entry ); |
17 | $this->titleParser = $titleParser; |
18 | } |
19 | |
20 | /** |
21 | * @inheritDoc |
22 | */ |
23 | protected function extractParameters() { |
24 | $params = parent::extractParameters(); |
25 | switch ( $this->entry->getSubtype() ) { |
26 | case 'claimmentee': |
27 | // logentry-growthexperiments-claimmentee |
28 | // @phan-suppress-next-line SecurityCheck-XSS |
29 | $params[4] = $this->formatParameterValue( 'user-link', $params[3] ); |
30 | // no break here |
31 | case 'claimmentee-no-previous-mentor': |
32 | // logentry-growthexperiments-claimmentee-no-previous-mentor |
33 | $params[5] = $this->formatParameterValue( 'user', $this->entry->getTarget()->getText() ); |
34 | break; |
35 | case 'setmentor': |
36 | // logentry-growthexperiments-setmentor |
37 | // @phan-suppress-next-line SecurityCheck-XSS |
38 | $params[7] = $this->formatParameterValue( 'user-link', $params[3] ); |
39 | // no break here |
40 | case 'setmentor-no-previous-mentor': |
41 | // logentry-growthexperiments-setmentor-no-previous-mentor |
42 | $params[5] = $this->formatParameterValue( 'user', $this->entry->getTarget()->getText() ); |
43 | // @phan-suppress-next-line SecurityCheck-XSS |
44 | $params[6] = $this->formatParameterValue( 'user-link', $params[4] ); |
45 | break; |
46 | } |
47 | return $params; |
48 | } |
49 | |
50 | /** |
51 | * @inheritDoc |
52 | */ |
53 | protected function getMessageParameters() { |
54 | $params = parent::getMessageParameters(); |
55 | // remove "User:" prefix |
56 | $params[2] = $this->formatParameterValue( 'user-link', $this->entry->getTarget()->getText() ); |
57 | return $params; |
58 | } |
59 | |
60 | /** |
61 | * @inheritDoc |
62 | */ |
63 | public function getPreloadTitles() { |
64 | // Add the mentee's and mentors' user pages to LinkBatch |
65 | $params = parent::getMessageParameters(); |
66 | $links = []; |
67 | switch ( $this->entry->getSubtype() ) { |
68 | case 'claimmentee': |
69 | $title = $this->titleParser->makeTitleValueSafe( NS_USER, $params[3] ); |
70 | if ( $title ) { |
71 | $links[] = $title; |
72 | } |
73 | break; |
74 | case 'setmentor': |
75 | $title = $this->titleParser->makeTitleValueSafe( NS_USER, $params[3] ); |
76 | if ( $title ) { |
77 | $links[] = $title; |
78 | } |
79 | // no break here |
80 | case 'setmentor-no-previous-mentor': |
81 | $title = $this->titleParser->makeTitleValueSafe( NS_USER, $params[4] ); |
82 | if ( $title ) { |
83 | $links[] = $title; |
84 | } |
85 | break; |
86 | } |
87 | return $links; |
88 | } |
89 | |
90 | } |