mediawiki-skins-Citizen/includes/Components/CitizenComponentMainMenu.php
alistair3149 03da361b97
feat(components): rewrite template data partials into CitizenComponent components (#846)
- Refactor existing template data-related partials into CitizenComponent components
- Re-implement user menu header as UserInfo
- Add description text for anon and temp user in UserMenu
---------

Co-authored-by: github-actions <github-actions@users.noreply.github.com>
2024-05-15 01:24:43 -04:00

44 lines
1 KiB
PHP

<?php
declare( strict_types=1 );
namespace MediaWiki\Skins\Citizen\Components;
/**
* CitizenComponentMainMenu component
*/
class CitizenComponentMainMenu implements CitizenComponent {
/** @var array */
private $sidebarData;
/**
* @param array $sidebarData
*/
public function __construct( array $sidebarData ) {
$this->sidebarData = $sidebarData;
}
/**
* @inheritDoc
*/
public function getTemplateData(): array {
$portletsRest = [];
foreach ( $this->sidebarData[ 'array-portlets-rest' ] as $data ) {
/**
* Remove toolbox from main menu as we moved it to article tools
* TODO: Move handling to SkinCitizen.php after we convert pagetools to component
*/
if ( $data['id'] === 'p-tb' ) {
continue;
}
$portletsRest[] = ( new CitizenComponentMenu( $data ) )->getTemplateData();
}
$firstPortlet = new CitizenComponentMenu( $this->sidebarData['data-portlets-first'] );
return [
'data-portlets-first' => $firstPortlet->getTemplateData(),
'array-portlets-rest' => $portletsRest
];
}
}