mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-24 15:53:46 +00:00
d2b413a721
Bug: T351141 Change-Id: Ic4a166fb3234b27dbf3d37891abfdf15781c8867
57 lines
1.3 KiB
PHP
57 lines
1.3 KiB
PHP
<?php
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
use MediaWiki\Skins\Vector\Constants;
|
|
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
|
|
use MessageLocalizer;
|
|
|
|
/**
|
|
* VectorComponentMainMenu component
|
|
*/
|
|
class VectorComponentClientPrefs implements VectorComponent {
|
|
|
|
/** @var MessageLocalizer */
|
|
private $localizer;
|
|
|
|
/** @var bool */
|
|
private $isPinned;
|
|
|
|
/** @var string */
|
|
public const ID = 'vector-client-prefs';
|
|
|
|
/**
|
|
* @param MessageLocalizer $localizer
|
|
* @param FeatureManager $featureManager
|
|
*/
|
|
public function __construct(
|
|
MessageLocalizer $localizer,
|
|
FeatureManager $featureManager
|
|
) {
|
|
$this->localizer = $localizer;
|
|
$this->isPinned = $featureManager->isFeatureEnabled( Constants::FEATURE_CLIENT_PREFS_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
|
|
'client-prefs-pinned'
|
|
);
|
|
|
|
$data = $pinnableElement->getTemplateData() +
|
|
$pinnedContainer->getTemplateData();
|
|
|
|
return $data + [
|
|
'data-pinnable-header' => $pinnableHeader->getTemplateData()
|
|
];
|
|
}
|
|
}
|