From 2d914d04ea8a4f27098d3dcecf60a5ffa6b4fa86 Mon Sep 17 00:00:00 2001 From: jdlrobson Date: Fri, 14 Feb 2020 12:05:18 -0800 Subject: [PATCH] Remove renderNavigation function for readability The renderNavigation function provides an unnecessary level of abstraction which I'd argue hurts readability of these functions. Let's remove it. Change-Id: Iad1c4db606404fecf4d5ae98981df9f05d3f661e --- includes/VectorTemplate.php | 43 +++++-------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/includes/VectorTemplate.php b/includes/VectorTemplate.php index 1d9e906..51d8f46 100644 --- a/includes/VectorTemplate.php +++ b/includes/VectorTemplate.php @@ -141,9 +141,11 @@ class VectorTemplate extends BaseTemplate { ] ), 'html-navigation' => $this->getTemplateParser()->processTemplate( 'Navigation', [ 'html-navigation-heading' => $this->getMsg( 'navigation-heading' ), - 'html-personal-menu' => $this->renderNavigation( [ 'PERSONAL' ] ), - 'html-navigation-left-tabs' => $this->renderNavigation( [ 'NAMESPACES', 'VARIANTS' ] ), - 'html-navigation-right-tabs' => $this->renderNavigation( [ 'VIEWS', 'ACTIONS', 'SEARCH' ] ), + 'html-personal-menu' => $this->renderPersonalComponent(), + 'html-navigation-left-tabs' => $this->renderNamespacesComponent() . + $this->renderVariantsComponent(), + 'html-navigation-right-tabs' => $this->renderViewsComponent() + . $this->renderActionsComponent() . $this->renderSearchComponent(), 'html-logo-attributes' => Xml::expandAttributes( Linker::tooltipAndAccesskeyAttribs( 'p-logo' ) + [ 'class' => 'mw-wiki-logo', @@ -301,41 +303,6 @@ class VectorTemplate extends BaseTemplate { return $this->getTemplateParser()->processTemplate( 'Portal', $props ); } - /** - * Render one or more navigations elements by name, automatically reversed by css - * when UI is in RTL mode - * - * @param array $elements - * @return string - */ - protected function renderNavigation( array $elements ) { - $html = ''; - // Render elements - foreach ( $elements as $name => $element ) { - switch ( $element ) { - case 'NAMESPACES': - $html .= $this->renderNamespacesComponent(); - break; - case 'VARIANTS': - $html .= $this->renderVariantsComponent(); - break; - case 'VIEWS': - $html .= $this->renderViewsComponent(); - break; - case 'ACTIONS': - $html .= $this->renderActionsComponent(); - break; - case 'PERSONAL': - $html .= $this->renderPersonalComponent(); - break; - case 'SEARCH': - $html .= $this->renderSearchComponent(); - break; - } - } - return $html; - } - /** * @inheritDoc */