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
This commit is contained in:
jdlrobson 2020-02-14 12:05:18 -08:00 committed by VolkerE
parent a79bb8dff4
commit 2d914d04ea
1 changed files with 5 additions and 38 deletions

View File

@ -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
*/