MediaWiki
1.42.1
UserBlockedError.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\Block\Block
;
22
use
MediaWiki\Context\RequestContext
;
23
use
MediaWiki\Language\RawMessage
;
24
use
MediaWiki\MediaWikiServices
;
25
use
MediaWiki\User\UserIdentity
;
26
34
class
UserBlockedError
extends
ErrorPageError
{
42
public
function
__construct
(
43
Block
$block,
44
UserIdentity
$user =
null
,
45
$language =
null
,
46
$ip =
null
47
) {
48
$context = RequestContext::getMain();
49
if
( $user ===
null
|| $ip ===
null
) {
50
// If any of these are not passed in, use the global context
51
$user = $context->getUser();
52
$ip = $context->getRequest()->getIP();
53
}
54
55
// @todo This should be passed in via the constructor
56
$messages = MediaWikiServices::getInstance()->getFormatterFactory()
57
->getBlockErrorFormatter( $context )
58
->getMessages( $block, $user, $ip );
59
60
if
( count( $messages ) === 1 ) {
61
$message = $messages[0];
62
}
else
{
63
$message =
new
RawMessage
(
'* $'
. implode(
"\n* \$"
, range( 1, count( $messages ) ) ) );
64
$message->params( $messages )->parse();
65
}
66
67
parent::__construct(
'blockedtitle'
, $message );
68
}
69
}
ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:30
MediaWiki\Context\RequestContext
Group all the pieces relevant to the context of a request into one instance.
Definition
RequestContext.php:66
MediaWiki\Language\RawMessage
Variant of the Message class.
Definition
RawMessage.php:40
MediaWiki\MediaWikiServices
Service locator for MediaWiki core services.
Definition
MediaWikiServices.php:241
UserBlockedError
Show an error when the user tries to do something whilst blocked.
Definition
UserBlockedError.php:34
UserBlockedError\__construct
__construct(Block $block, UserIdentity $user=null, $language=null, $ip=null)
Definition
UserBlockedError.php:42
MediaWiki\Block\Block
Represents a block that may prevent users from performing specific operations.
Definition
Block.php:45
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition
UserIdentity.php:39
includes
exception
UserBlockedError.php
Generated on Thu Jun 27 2024 15:58:44 for MediaWiki by
1.10.0