mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-12-03 11:46:43 +00:00
15d95fc24a
Changes: * Code is moved from SkinVector to SkinVectorLegacy verbatim since it is now only needed by SkinVectorLegacy so we remove it: ** This step broke MainMenu rendering so this was captured in VectorComponentMainMenu ** The isLegacy code no longer makes sense and is removed in a follow up * storybook no longer run on CI Authors: Bernard Wang and Jon Robson Bug: T321102 Bug: T319349 Change-Id: Ib424ca1c767161fdae8c0aeedfe662b7fa039ff6
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
use Skin;
|
|
|
|
/**
|
|
* VectorComponentMainMenu component
|
|
*/
|
|
class VectorComponentMainMenu implements VectorComponent {
|
|
/** @var VectorComponent|null */
|
|
private $optOut;
|
|
/** @var VectorComponent|null */
|
|
private $alert;
|
|
/** @var array */
|
|
private $sidebarData;
|
|
|
|
/**
|
|
* @param array $sidebarData
|
|
* @param Skin $skin
|
|
* @param bool $shouldLanguageAlertBeInSidebar
|
|
*/
|
|
public function __construct(
|
|
array $sidebarData,
|
|
Skin $skin,
|
|
bool $shouldLanguageAlertBeInSidebar
|
|
) {
|
|
$this->sidebarData = $sidebarData;
|
|
$user = $skin->getUser();
|
|
if ( $user->isRegistered() ) {
|
|
$this->optOut = new VectorComponentMainMenuActionOptOut( $skin );
|
|
}
|
|
if ( $shouldLanguageAlertBeInSidebar ) {
|
|
$this->alert = new VectorComponentMainMenuActionLanguageSwitchAlert( $skin );
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getTemplateData(): array {
|
|
$action = $this->optOut;
|
|
$alert = $this->alert;
|
|
|
|
return $this->sidebarData + [
|
|
'data-main-menu-action' => $action ? $action->getTemplateData() : null,
|
|
// T295555 Add language switch alert message temporarily (to be removed).
|
|
'data-vector-language-switch-alert' => $alert ? $alert->getTemplateData() : null,
|
|
];
|
|
}
|
|
}
|