MediaWiki master
UserBlockedError.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Exception;
8
14
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
60class_alias( UserBlockedError::class, 'UserBlockedError' );
Group all the pieces relevant to the context of a request into one instance.
An error page which can definitely be safely rendered using the OutputPage.
Show an error when the user tries to do something whilst blocked.
__construct(Block $block, ?UserIdentity $user=null, $language=null, $ip=null)
Variant of the Message class.
Service locator for MediaWiki core services.
static getInstance()
Returns the global default instance of the top level service locator.
Represents a block that may prevent users from performing specific operations.
Definition Block.php:31
Interface for objects representing user identity.