mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-18 19:00:50 +00:00
0109218ab9
Bug: T362808 Change-Id: Id6800d38eebf433cf0c9e3f179dd83df2eefd1fb
58 lines
1.4 KiB
PHP
58 lines
1.4 KiB
PHP
<?php
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
use MediaWiki\Skins\Vector\Constants;
|
|
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
|
|
use MessageLocalizer;
|
|
|
|
/**
|
|
* VectorComponentAppearance component
|
|
*/
|
|
class VectorComponentAppearance implements VectorComponent {
|
|
|
|
/** @var MessageLocalizer */
|
|
private $localizer;
|
|
|
|
/** @var bool */
|
|
private $isPinned;
|
|
|
|
/** @var string */
|
|
public const ID = 'vector-appearance';
|
|
|
|
/**
|
|
* @param MessageLocalizer $localizer
|
|
* @param FeatureManager $featureManager
|
|
*/
|
|
public function __construct(
|
|
MessageLocalizer $localizer,
|
|
FeatureManager $featureManager
|
|
) {
|
|
$this->localizer = $localizer;
|
|
// FIXME: isPinned is no longer accurate because the appearance menu uses client preferences
|
|
$this->isPinned = $featureManager->isFeatureEnabled( Constants::FEATURE_APPEARANCE_PINNED );
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getTemplateData(): array {
|
|
$pinnedContainer = new VectorComponentPinnableContainer( self::ID, $this->isPinned );
|
|
$pinnableElement = new VectorComponentPinnableElement( self::ID );
|
|
$pinnableHeader = new VectorComponentPinnableHeader(
|
|
$this->localizer,
|
|
$this->isPinned,
|
|
// Name
|
|
self::ID,
|
|
// Feature name
|
|
'appearance-pinned'
|
|
);
|
|
|
|
$data = $pinnableElement->getTemplateData() +
|
|
$pinnedContainer->getTemplateData();
|
|
|
|
return $data + [
|
|
'data-pinnable-header' => $pinnableHeader->getTemplateData()
|
|
];
|
|
}
|
|
}
|