Factor out data required for creating a logout link

Factors out logic that's responsible for assembling data for the logout
link in a public SkinTemplate::buildLogoutLinkData function.

This function is required by the new version of the Vector skin to
reposition the logout button outside of the personal tools menu.

Bug: T281791
Change-Id: If82a736e37174aaadd0ff07019a1fae3759a9e51
This commit is contained in:
Jan Drewniak 2021-06-09 22:59:28 +02:00
parent 25d5e0513a
commit d638cad995

View file

@ -574,15 +574,7 @@ class SkinTemplate extends Skin {
// if we can't set the user, we can't unset it either
if ( $request->getSession()->canSetUser() ) {
$personal_urls['logout'] = [
'text' => $this->msg( 'pt-userlogout' )->text(),
'data-mw' => 'interface',
'href' => self::makeSpecialUrl( 'Userlogout',
// Note: userlogout link must always contain an & character, otherwise we might not be able
// to detect a buggy precaching proxy (T19790)
( $title->isSpecial( 'Preferences' ) ? [] : $returnto ) ),
'active' => false
];
$personal_urls['logout'] = $this->buildLogoutLinkData();
}
} else {
$useCombinedLoginLink = $this->useCombinedLoginLink();
@ -717,6 +709,30 @@ class SkinTemplate extends Skin {
return $login_url;
}
/**
* Build data required for "Logout" link.
*
* @unstable
*
* @since 1.37
*
* @return array Array of data required to create a logout link.
*/
final protected function buildLogoutLinkData() {
$title = $this->getTitle();
$returnto = $this->getReturnToParam();
return [
'text' => $this->msg( 'pt-userlogout' )->text(),
'data-mw' => 'interface',
'href' => self::makeSpecialUrl( 'Userlogout',
// Note: userlogout link must always contain an & character, otherwise we might not be able
// to detect a buggy precaching proxy (T19790)
( $title->isSpecial( 'Preferences' ) ? [] : $returnto ) ),
'active' => false
];
}
/**
* Build "Create Account" link
* @unstable