Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
86.67% |
13 / 15 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
VectorComponentAppearance | |
86.67% |
13 / 15 |
|
50.00% |
1 / 2 |
2.01 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
getTemplateData | |
100.00% |
13 / 13 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | namespace MediaWiki\Skins\Vector\Components; |
3 | |
4 | use MediaWiki\Skins\Vector\Constants; |
5 | use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager; |
6 | use MessageLocalizer; |
7 | |
8 | /** |
9 | * VectorComponentAppearance component |
10 | */ |
11 | class VectorComponentAppearance implements VectorComponent { |
12 | |
13 | /** @var MessageLocalizer */ |
14 | private $localizer; |
15 | |
16 | /** @var bool */ |
17 | private $isPinned; |
18 | |
19 | /** @var string */ |
20 | public const ID = 'vector-appearance'; |
21 | |
22 | /** |
23 | * @param MessageLocalizer $localizer |
24 | * @param FeatureManager $featureManager |
25 | */ |
26 | public function __construct( |
27 | MessageLocalizer $localizer, |
28 | FeatureManager $featureManager |
29 | ) { |
30 | $this->localizer = $localizer; |
31 | // FIXME: isPinned is no longer accurate because the appearance menu uses client preferences |
32 | $this->isPinned = $featureManager->isFeatureEnabled( Constants::FEATURE_APPEARANCE_PINNED ); |
33 | } |
34 | |
35 | /** |
36 | * @inheritDoc |
37 | */ |
38 | public function getTemplateData(): array { |
39 | $pinnedContainer = new VectorComponentPinnableContainer( self::ID, $this->isPinned ); |
40 | $pinnableElement = new VectorComponentPinnableElement( self::ID ); |
41 | $pinnableHeader = new VectorComponentPinnableHeader( |
42 | $this->localizer, |
43 | $this->isPinned, |
44 | // Name |
45 | self::ID, |
46 | // Feature name |
47 | 'appearance-pinned' |
48 | ); |
49 | |
50 | $data = $pinnableElement->getTemplateData() + |
51 | $pinnedContainer->getTemplateData(); |
52 | |
53 | return $data + [ |
54 | 'data-pinnable-header' => $pinnableHeader->getTemplateData() |
55 | ]; |
56 | } |
57 | } |