mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/Nuke
synced 2024-11-15 03:35:39 +00:00
Inject services
Change-Id: I7f11825af2bb96ad61aa2cefcc47fcad706388af
This commit is contained in:
parent
6f8f4d759f
commit
49df51e106
|
@ -58,7 +58,14 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"SpecialPages": {
|
"SpecialPages": {
|
||||||
"Nuke": "MediaWiki\\Extension\\Nuke\\SpecialNuke"
|
"Nuke": {
|
||||||
|
"class": "MediaWiki\\Extension\\Nuke\\SpecialNuke",
|
||||||
|
"services": [
|
||||||
|
"JobQueueGroup",
|
||||||
|
"PermissionManager",
|
||||||
|
"RepoGroup"
|
||||||
|
]
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"AutoloadNamespaces": {
|
"AutoloadNamespaces": {
|
||||||
"MediaWiki\\Extension\\Nuke\\": "includes/"
|
"MediaWiki\\Extension\\Nuke\\": "includes/"
|
||||||
|
|
|
@ -7,13 +7,15 @@ use DeletePageJob;
|
||||||
use FileDeleteForm;
|
use FileDeleteForm;
|
||||||
use Html;
|
use Html;
|
||||||
use HTMLForm;
|
use HTMLForm;
|
||||||
|
use JobQueueGroup;
|
||||||
use ListToggle;
|
use ListToggle;
|
||||||
use MediaWiki\Extension\Nuke\Hooks\NukeHookRunner;
|
use MediaWiki\Extension\Nuke\Hooks\NukeHookRunner;
|
||||||
use MediaWiki\MediaWikiServices;
|
use MediaWiki\Permissions\PermissionManager;
|
||||||
use OOUI\DropdownInputWidget;
|
use OOUI\DropdownInputWidget;
|
||||||
use OOUI\FieldLayout;
|
use OOUI\FieldLayout;
|
||||||
use OOUI\TextInputWidget;
|
use OOUI\TextInputWidget;
|
||||||
use PermissionsError;
|
use PermissionsError;
|
||||||
|
use RepoGroup;
|
||||||
use SpecialPage;
|
use SpecialPage;
|
||||||
use Title;
|
use Title;
|
||||||
use User;
|
use User;
|
||||||
|
@ -27,9 +29,30 @@ class SpecialNuke extends SpecialPage {
|
||||||
/** @var NukeHookRunner */
|
/** @var NukeHookRunner */
|
||||||
private $hookRunner;
|
private $hookRunner;
|
||||||
|
|
||||||
public function __construct() {
|
/** @var JobQueueGroup */
|
||||||
|
private $jobQueueGroup;
|
||||||
|
|
||||||
|
/** @var PermissionManager */
|
||||||
|
private $permissionManager;
|
||||||
|
|
||||||
|
/** @var RepoGroup */
|
||||||
|
private $repoGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param JobQueueGroup $jobQueueGroup
|
||||||
|
* @param PermissionManager $permissionManager
|
||||||
|
* @param RepoGroup $repoGroup
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
JobQueueGroup $jobQueueGroup,
|
||||||
|
PermissionManager $permissionManager,
|
||||||
|
RepoGroup $repoGroup
|
||||||
|
) {
|
||||||
parent::__construct( 'Nuke', 'nuke' );
|
parent::__construct( 'Nuke', 'nuke' );
|
||||||
$this->hookRunner = new NukeHookRunner( $this->getHookContainer() );
|
$this->hookRunner = new NukeHookRunner( $this->getHookContainer() );
|
||||||
|
$this->jobQueueGroup = $jobQueueGroup;
|
||||||
|
$this->permissionManager = $permissionManager;
|
||||||
|
$this->repoGroup = $repoGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function doesWrites() {
|
public function doesWrites() {
|
||||||
|
@ -246,7 +269,7 @@ class SpecialNuke extends SpecialPage {
|
||||||
$commaSeparator = $this->msg( 'comma-separator' )->escaped();
|
$commaSeparator = $this->msg( 'comma-separator' )->escaped();
|
||||||
|
|
||||||
$linkRenderer = $this->getLinkRenderer();
|
$linkRenderer = $this->getLinkRenderer();
|
||||||
$localRepo = MediaWikiServices::getInstance()->getRepoGroup()->getLocalRepo();
|
$localRepo = $this->repoGroup->getLocalRepo();
|
||||||
foreach ( $pages as $info ) {
|
foreach ( $pages as $info ) {
|
||||||
/**
|
/**
|
||||||
* @var $title Title
|
* @var $title Title
|
||||||
|
@ -377,9 +400,7 @@ class SpecialNuke extends SpecialPage {
|
||||||
$jobs = [];
|
$jobs = [];
|
||||||
$user = $this->getUser();
|
$user = $this->getUser();
|
||||||
|
|
||||||
$services = MediaWikiServices::getInstance();
|
$localRepo = $this->repoGroup->getLocalRepo();
|
||||||
$localRepo = $services->getRepoGroup()->getLocalRepo();
|
|
||||||
$permissionManager = $services->getPermissionManager();
|
|
||||||
foreach ( $pages as $page ) {
|
foreach ( $pages as $page ) {
|
||||||
$title = Title::newFromText( $page );
|
$title = Title::newFromText( $page );
|
||||||
|
|
||||||
|
@ -397,7 +418,7 @@ class SpecialNuke extends SpecialPage {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$permission_errors = $permissionManager->getPermissionErrors( 'delete', $user, $title );
|
$permission_errors = $this->permissionManager->getPermissionErrors( 'delete', $user, $title );
|
||||||
|
|
||||||
if ( $permission_errors !== [] ) {
|
if ( $permission_errors !== [] ) {
|
||||||
throw new PermissionsError( 'delete', $permission_errors );
|
throw new PermissionsError( 'delete', $permission_errors );
|
||||||
|
@ -445,7 +466,7 @@ class SpecialNuke extends SpecialPage {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $jobs ) {
|
if ( $jobs ) {
|
||||||
MediaWikiServices::getInstance()->getJobQueueGroup()->push( $jobs );
|
$this->jobQueueGroup->push( $jobs );
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->getOutput()->addHTML(
|
$this->getOutput()->addHTML(
|
||||||
|
|
Loading…
Reference in a new issue