MediaWiki
master
Toggle main menu visibility
UserBlockedError.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki\Exception;
8
9
use MediaWiki\Block\Block;
10
use MediaWiki\Context\RequestContext;
11
use MediaWiki\Language\RawMessage;
12
use MediaWiki\MediaWikiServices;
13
use MediaWiki\User\UserIdentity;
14
22
class
UserBlockedError
extends
ErrorPageError
{
30
public
function
__construct
(
31
Block
$block,
32
?
UserIdentity
$user =
null
,
33
$language =
null
,
34
$ip =
null
35
) {
36
$context = RequestContext::getMain();
37
if
( $user ===
null
|| $ip ===
null
) {
38
// If any of these are not passed in, use the global context
39
$user = $context->getUser();
40
$ip = $context->getRequest()->getIP();
41
}
42
43
// @todo This should be passed in via the constructor
44
$messages =
MediaWikiServices::getInstance
()->getFormatterFactory()
45
->getBlockErrorFormatter( $context )
46
->getMessages( $block, $user, $ip );
47
48
if
( count( $messages ) === 1 ) {
49
$message = $messages[0];
50
}
else
{
51
$message =
new
RawMessage
(
'* $'
. implode(
"\n* \$"
, range( 1, count( $messages ) ) ) );
52
$message->params( $messages )->parse();
53
}
54
55
parent::__construct(
'blockedtitle'
, $message );
56
}
57
}
58
60
class_alias( UserBlockedError::class,
'UserBlockedError'
);
MediaWiki\Exception\ErrorPageError
An error page which can definitely be safely rendered using the OutputPage.
Definition
ErrorPageError.php:21
MediaWiki\Exception\UserBlockedError
Show an error when the user tries to do something whilst blocked.
Definition
UserBlockedError.php:22
MediaWiki\Exception\UserBlockedError\__construct
__construct(Block $block, ?UserIdentity $user=null, $language=null, $ip=null)
Definition
UserBlockedError.php:30
MediaWiki\Language\RawMessage
Variant of the Message class.
Definition
RawMessage.php:25
MediaWiki\MediaWikiServices\getInstance
static getInstance()
Returns the global default instance of the top level service locator.
Definition
MediaWikiServices.php:361
MediaWiki\Block\Block
Represents a block that may prevent users from performing specific operations.
Definition
Block.php:32
MediaWiki\User\UserIdentity
Interface for objects representing user identity.
Definition
UserIdentity.php:24
includes
Exception
UserBlockedError.php
Generated on
for MediaWiki by
1.18.0