Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
VectorComponentMainMenuActionOptOut | |
0.00% |
0 / 17 |
|
0.00% |
0 / 2 |
6 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getTemplateData | |
0.00% |
0 / 16 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | namespace MediaWiki\Skins\Vector\Components; |
3 | |
4 | use MediaWiki\SpecialPage\SpecialPage; |
5 | use Skin; |
6 | |
7 | /** |
8 | * VectorComponentMainMenuActionOptOut component |
9 | */ |
10 | class VectorComponentMainMenuActionOptOut implements VectorComponent { |
11 | /** @var Skin */ |
12 | private $skin; |
13 | |
14 | /** |
15 | * T243281: Code used to track clicks to opt-out link. |
16 | * |
17 | * The "vct" substring is used to describe the newest "Vector" (non-legacy) |
18 | * feature. The "w" describes the web platform. The "1" describes the version |
19 | * of the feature. |
20 | * |
21 | * @see https://wikitech.wikimedia.org/wiki/Provenance |
22 | * @var string |
23 | */ |
24 | private const OPT_OUT_LINK_TRACKING_CODE = 'vctw1'; |
25 | |
26 | /** |
27 | * @param Skin $skin |
28 | */ |
29 | public function __construct( Skin $skin ) { |
30 | $this->skin = $skin; |
31 | } |
32 | |
33 | /** |
34 | * @inheritDoc |
35 | */ |
36 | public function getTemplateData(): array { |
37 | $skin = $this->skin; |
38 | // Note: This data is also passed to legacy template where it is unused. |
39 | $optOutUrl = [ |
40 | 'text' => $skin->msg( 'vector-opt-out' )->text(), |
41 | 'href' => SpecialPage::getTitleFor( |
42 | 'Preferences', |
43 | false, |
44 | 'mw-prefsection-rendering-skin' |
45 | )->getLinkURL( 'useskin=vector&wprov=' . self::OPT_OUT_LINK_TRACKING_CODE ), |
46 | 'title' => $skin->msg( 'vector-opt-out-tooltip' )->text(), |
47 | 'active' => false, |
48 | ]; |
49 | $htmlData = [ |
50 | 'link' => $optOutUrl, |
51 | ]; |
52 | $component = new VectorComponentMainMenuAction( 'opt-out', $skin, $htmlData, [] ); |
53 | return $component->getTemplateData(); |
54 | } |
55 | } |