mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-12-01 09:16:34 +00:00
Merge "Replace usage of deprecated User watchlist methods"
This commit is contained in:
commit
a42560c1c9
|
@ -32,6 +32,7 @@ use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
|
||||||
use MediaWiki\Minerva\SkinOptions;
|
use MediaWiki\Minerva\SkinOptions;
|
||||||
use MediaWiki\Minerva\Skins\SkinUserPageHelper;
|
use MediaWiki\Minerva\Skins\SkinUserPageHelper;
|
||||||
use MediaWiki\User\UserIdentity;
|
use MediaWiki\User\UserIdentity;
|
||||||
|
use MediaWiki\Watchlist\WatchlistManager;
|
||||||
use MessageLocalizer;
|
use MessageLocalizer;
|
||||||
use MinervaUI;
|
use MinervaUI;
|
||||||
use MWException;
|
use MWException;
|
||||||
|
@ -80,6 +81,11 @@ class ToolbarBuilder {
|
||||||
*/
|
*/
|
||||||
private $watchlistExpiryEnabled;
|
private $watchlistExpiryEnabled;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var WatchlistManager
|
||||||
|
*/
|
||||||
|
private $watchlistManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ServiceOptions needed.
|
* ServiceOptions needed.
|
||||||
*/
|
*/
|
||||||
|
@ -100,6 +106,7 @@ class ToolbarBuilder {
|
||||||
* Title and NOT with the user talk page Title.
|
* Title and NOT with the user talk page Title.
|
||||||
* @param LanguagesHelper $languagesHelper Helper to check title languages/variants
|
* @param LanguagesHelper $languagesHelper Helper to check title languages/variants
|
||||||
* @param ServiceOptions $options
|
* @param ServiceOptions $options
|
||||||
|
* @param WatchlistManager $watchlistManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Title $title,
|
Title $title,
|
||||||
|
@ -109,7 +116,8 @@ class ToolbarBuilder {
|
||||||
SkinOptions $skinOptions,
|
SkinOptions $skinOptions,
|
||||||
SkinUserPageHelper $relevantUserPageHelper,
|
SkinUserPageHelper $relevantUserPageHelper,
|
||||||
LanguagesHelper $languagesHelper,
|
LanguagesHelper $languagesHelper,
|
||||||
ServiceOptions $options
|
ServiceOptions $options,
|
||||||
|
WatchlistManager $watchlistManager
|
||||||
) {
|
) {
|
||||||
$this->title = $title;
|
$this->title = $title;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
|
@ -119,6 +127,7 @@ class ToolbarBuilder {
|
||||||
$this->relevantUserPageHelper = $relevantUserPageHelper;
|
$this->relevantUserPageHelper = $relevantUserPageHelper;
|
||||||
$this->languagesHelper = $languagesHelper;
|
$this->languagesHelper = $languagesHelper;
|
||||||
$this->watchlistExpiryEnabled = $options->get( 'WatchlistExpiry' );
|
$this->watchlistExpiryEnabled = $options->get( 'WatchlistExpiry' );
|
||||||
|
$this->watchlistManager = $watchlistManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -236,10 +245,11 @@ class ToolbarBuilder {
|
||||||
* @throws MWException
|
* @throws MWException
|
||||||
*/
|
*/
|
||||||
protected function createWatchPageAction(): IMenuEntry {
|
protected function createWatchPageAction(): IMenuEntry {
|
||||||
$isWatched = $this->user->isRegistered() && $this->user->isWatched( $this->title );
|
$isWatched = $this->user->isRegistered() &&
|
||||||
|
$this->watchlistManager->isWatched( $this->user, $this->title );
|
||||||
$isTempWatched = $this->watchlistExpiryEnabled &&
|
$isTempWatched = $this->watchlistExpiryEnabled &&
|
||||||
$isWatched &&
|
$isWatched &&
|
||||||
$this->user->isTempWatched( $this->title );
|
$this->watchlistManager->isTempWatched( $this->user, $this->title );
|
||||||
$newModeToSet = $isWatched ? 'unwatch' : 'watch';
|
$newModeToSet = $isWatched ? 'unwatch' : 'watch';
|
||||||
$href = $this->user->isAnon()
|
$href = $this->user->isAnon()
|
||||||
? $this->getLoginUrl( [ 'returnto' => $this->title ] )
|
? $this->getLoginUrl( [ 'returnto' => $this->title ] )
|
||||||
|
|
|
@ -93,6 +93,8 @@ return [
|
||||||
) :
|
) :
|
||||||
$userPageHelper;
|
$userPageHelper;
|
||||||
|
|
||||||
|
$watchlistManager = $services->getWatchlistManager();
|
||||||
|
|
||||||
$toolbarBuilder = new PageActionsMenu\ToolbarBuilder(
|
$toolbarBuilder = new PageActionsMenu\ToolbarBuilder(
|
||||||
$title,
|
$title,
|
||||||
$user,
|
$user,
|
||||||
|
@ -102,7 +104,8 @@ return [
|
||||||
$relevantUserPageHelper,
|
$relevantUserPageHelper,
|
||||||
$languagesHelper,
|
$languagesHelper,
|
||||||
new ServiceOptions( PageActionsMenu\ToolbarBuilder::CONSTRUCTOR_OPTIONS,
|
new ServiceOptions( PageActionsMenu\ToolbarBuilder::CONSTRUCTOR_OPTIONS,
|
||||||
$services->getMainConfig() )
|
$services->getMainConfig() ),
|
||||||
|
$watchlistManager
|
||||||
);
|
);
|
||||||
if ( $skinOptions->get( SkinOptions::TOOLBAR_SUBMENU ) ) {
|
if ( $skinOptions->get( SkinOptions::TOOLBAR_SUBMENU ) ) {
|
||||||
$overflowBuilder = $relevantUserPageHelper->isUserPage() ?
|
$overflowBuilder = $relevantUserPageHelper->isUserPage() ?
|
||||||
|
|
Loading…
Reference in a new issue