MediaWiki
master
PermissionsError.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\Context\RequestContext
;
22
use
MediaWiki\MediaWikiServices
;
23
use
MediaWiki\Message\Message
;
24
use
MediaWiki\Permissions\PermissionStatus
;
25
34
class
PermissionsError
extends
ErrorPageError
{
35
public
?
string
$permission
;
36
public
array
$errors
;
37
46
public
function
__construct
( ?
string
$permission, $errors = [] ) {
47
if
( $errors instanceof
PermissionStatus
) {
48
$errors = $errors->toLegacyErrorArray();
49
}
50
51
if
( $permission ===
null
&& !$errors ) {
52
throw
new \InvalidArgumentException( __METHOD__ .
53
': $permission and $errors cannot both be empty'
);
54
}
55
56
$this->permission = $permission;
57
58
if
( !count( $errors ) ) {
59
$errors = MediaWikiServices::getInstance()
60
->getPermissionManager()
61
// @phan-suppress-next-line PhanTypeMismatchArgumentNullable Null on permission is check when used here
62
->newFatalPermissionDeniedStatus( $this->permission, RequestContext::getMain() )
63
->toLegacyErrorArray();
64
}
65
66
$this->errors = $errors;
67
68
// Give the parent class something to work with
69
parent::__construct(
'permissionserrors'
, Message::newFromSpecifier( $errors[0] ) );
70
}
71
72
public
function
report
( $action = self::SEND_OUTPUT ) {
73
global
$wgOut
;
74
75
$wgOut
->showPermissionsErrorPage( $this->errors, $this->permission );
76
if
( $action === self::SEND_OUTPUT ) {
77
$wgOut
->output();
78
}
79
}
80
}
$wgOut
if(!defined( 'MW_NO_SESSION') &&MW_ENTRY_POINT !=='cli' $wgOut
Definition
Setup.php:538
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:32
MediaWiki\Context\RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition
RequestContext.php:67
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
Definition
MediaWikiServices.php:239
MediaWiki\Message\Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition
Message.php:158
MediaWiki\Permissions\PermissionStatus
A StatusValue for permission errors.
Definition
PermissionStatus.php:39
PermissionsError
Show an error when a user tries to do something they do not have the necessary permissions for.
Definition
PermissionsError.php:34
PermissionsError\$permission
string $permission
Definition
PermissionsError.php:35
PermissionsError\$errors
array $errors
Definition
PermissionsError.php:36
PermissionsError\report
report( $action=self::SEND_OUTPUT)
Definition
PermissionsError.php:72
PermissionsError\__construct
__construct(?string $permission, $errors=[])
Definition
PermissionsError.php:46
includes
exception
PermissionsError.php
Generated on Fri Jul 26 2024 23:23:12 for MediaWiki by
1.10.0