mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/MinervaNeue
synced 2024-11-24 06:13:54 +00:00
Inject service WatchlistManager into MinervaPagePermissions
Change-Id: Id41c85c8e119efbf9814be25ba659f1da1151eb4
This commit is contained in:
parent
c94c90d93d
commit
248180ef03
|
@ -24,13 +24,13 @@ use IContextSource;
|
||||||
use MediaWiki\Config\Config;
|
use MediaWiki\Config\Config;
|
||||||
use MediaWiki\Config\ConfigException;
|
use MediaWiki\Config\ConfigException;
|
||||||
use MediaWiki\Content\IContentHandlerFactory;
|
use MediaWiki\Content\IContentHandlerFactory;
|
||||||
use MediaWiki\MediaWikiServices;
|
|
||||||
use MediaWiki\Minerva\LanguagesHelper;
|
use MediaWiki\Minerva\LanguagesHelper;
|
||||||
use MediaWiki\Minerva\SkinOptions;
|
use MediaWiki\Minerva\SkinOptions;
|
||||||
use MediaWiki\Permissions\Authority;
|
use MediaWiki\Permissions\Authority;
|
||||||
use MediaWiki\Permissions\PermissionManager;
|
use MediaWiki\Permissions\PermissionManager;
|
||||||
use MediaWiki\Title\Title;
|
use MediaWiki\Title\Title;
|
||||||
use MediaWiki\User\UserFactory;
|
use MediaWiki\User\UserFactory;
|
||||||
|
use MediaWiki\Watchlist\WatchlistManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper for all available Minerva permissions.
|
* A wrapper for all available Minerva permissions.
|
||||||
|
@ -77,6 +77,8 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
||||||
|
|
||||||
private UserFactory $userFactory;
|
private UserFactory $userFactory;
|
||||||
|
|
||||||
|
private WatchlistManager $watchlistManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize internal Minerva Permissions system
|
* Initialize internal Minerva Permissions system
|
||||||
* @param SkinOptions $skinOptions
|
* @param SkinOptions $skinOptions
|
||||||
|
@ -84,19 +86,22 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
||||||
* @param PermissionManager $permissionManager
|
* @param PermissionManager $permissionManager
|
||||||
* @param IContentHandlerFactory $contentHandlerFactory
|
* @param IContentHandlerFactory $contentHandlerFactory
|
||||||
* @param UserFactory $userFactory
|
* @param UserFactory $userFactory
|
||||||
|
* @param WatchlistManager $watchlistManager
|
||||||
*/
|
*/
|
||||||
public function __construct(
|
public function __construct(
|
||||||
SkinOptions $skinOptions,
|
SkinOptions $skinOptions,
|
||||||
LanguagesHelper $languagesHelper,
|
LanguagesHelper $languagesHelper,
|
||||||
PermissionManager $permissionManager,
|
PermissionManager $permissionManager,
|
||||||
IContentHandlerFactory $contentHandlerFactory,
|
IContentHandlerFactory $contentHandlerFactory,
|
||||||
UserFactory $userFactory
|
UserFactory $userFactory,
|
||||||
|
WatchlistManager $watchlistManager
|
||||||
) {
|
) {
|
||||||
$this->skinOptions = $skinOptions;
|
$this->skinOptions = $skinOptions;
|
||||||
$this->languagesHelper = $languagesHelper;
|
$this->languagesHelper = $languagesHelper;
|
||||||
$this->permissionManager = $permissionManager;
|
$this->permissionManager = $permissionManager;
|
||||||
$this->contentHandlerFactory = $contentHandlerFactory;
|
$this->contentHandlerFactory = $contentHandlerFactory;
|
||||||
$this->userFactory = $userFactory;
|
$this->userFactory = $userFactory;
|
||||||
|
$this->watchlistManager = $watchlistManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -177,7 +182,7 @@ final class MinervaPagePermissions implements IMinervaPagePermissions {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $action === self::WATCHABLE || $action === self::WATCH ) {
|
if ( $action === self::WATCHABLE || $action === self::WATCH ) {
|
||||||
$isWatchable = MediaWikiServices::getInstance()->getWatchlistManager()->isWatchable( $this->title );
|
$isWatchable = $this->watchlistManager->isWatchable( $this->title );
|
||||||
|
|
||||||
if ( $action === self::WATCHABLE ) {
|
if ( $action === self::WATCHABLE ) {
|
||||||
return $isWatchable;
|
return $isWatchable;
|
||||||
|
|
|
@ -162,7 +162,8 @@ return [
|
||||||
$services->getService( 'Minerva.LanguagesHelper' ),
|
$services->getService( 'Minerva.LanguagesHelper' ),
|
||||||
$services->getPermissionManager(),
|
$services->getPermissionManager(),
|
||||||
$services->getContentHandlerFactory(),
|
$services->getContentHandlerFactory(),
|
||||||
$services->getUserFactory()
|
$services->getUserFactory(),
|
||||||
|
$services->getWatchlistManager()
|
||||||
);
|
);
|
||||||
// TODO: This should not be allowed, this is basically global $wgTitle and $wgUser.
|
// TODO: This should not be allowed, this is basically global $wgTitle and $wgUser.
|
||||||
$permissions->setContext( RequestContext::getMain() );
|
$permissions->setContext( RequestContext::getMain() );
|
||||||
|
|
|
@ -74,7 +74,8 @@ class MinervaPagePermissionsTest extends MediaWikiIntegrationTestCase {
|
||||||
$languageHelper,
|
$languageHelper,
|
||||||
$permissionManager,
|
$permissionManager,
|
||||||
$contentHandlerFactory,
|
$contentHandlerFactory,
|
||||||
$this->createMock( UserFactory::class )
|
$this->createMock( UserFactory::class ),
|
||||||
|
$this->getServiceContainer()->getWatchlistManager()
|
||||||
) )->setContext( $context );
|
) )->setContext( $context );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue