From df681e031dbd00bc3883459f88dddf74ed488571 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Tue, 28 Apr 2020 10:44:39 -0700 Subject: [PATCH] Add buildSidebar method Move all the sidebar generation logic into a new VectorTemplate function. The name mirrors the function name in SkinVector. In future, ( I7a14f74728703c50874935e9d77b35ad9434b436) we will move this code into SkinVector where it will be able to call parent::buildSidebar() Bug: T251212 Change-Id: I0a4838120f6ffd3d3d798f876e3463a3f16af95b --- includes/VectorTemplate.php | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index f9b2930..ef664b8 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -189,15 +189,7 @@ class VectorTemplate extends BaseTemplate { ], 'html-navigation-heading' => $this->getMsg( 'navigation-heading' ), 'data-search-box' => $this->buildSearchProps(), - 'data-sidebar' => [ - 'has-logo' => true, - 'html-logo-attributes' => Xml::expandAttributes( - Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [ - 'class' => 'mw-wiki-logo', - 'href' => Skin::makeMainPageUrl(), - ] - ) - ] + $this->buildSidebarProps( $this->get( 'sidebar', [] ) ), + 'data-sidebar' => $this->buildSidebar(), ] + $this->getMenuProps(); // The following logic is unqiue to Vector (not used by legacy Vector) and @@ -276,10 +268,10 @@ class VectorTemplate extends BaseTemplate { /** * Render a series of portals * - * @param array $portals * @return array */ - private function buildSidebarProps( array $portals ) : array { + private function buildSidebar() : array { + $portals = $this->get( 'sidebar', [] ); $props = []; // Force the rendering of the following portals if ( !isset( $portals['TOOLBOX'] ) ) { @@ -328,6 +320,13 @@ class VectorTemplate extends BaseTemplate { } return [ + 'has-logo' => true, + 'html-logo-attributes' => Xml::expandAttributes( + Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [ + 'class' => 'mw-wiki-logo', + 'href' => Skin::makeMainPageUrl(), + ] + ), 'array-portals-rest' => array_slice( $props, 1 ), 'array-portals-first' => $firstPortal, ];