MediaWiki master
UserBlockedError.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Exception;
22
28
44 public function __construct(
45 Block $block,
46 ?UserIdentity $user = null,
47 $language = null,
48 $ip = null
49 ) {
50 $context = RequestContext::getMain();
51 if ( $user === null || $ip === null ) {
52 // If any of these are not passed in, use the global context
53 $user = $context->getUser();
54 $ip = $context->getRequest()->getIP();
55 }
56
57 // @todo This should be passed in via the constructor
58 $messages = MediaWikiServices::getInstance()->getFormatterFactory()
59 ->getBlockErrorFormatter( $context )
60 ->getMessages( $block, $user, $ip );
61
62 if ( count( $messages ) === 1 ) {
63 $message = $messages[0];
64 } else {
65 $message = new RawMessage( '* $' . implode( "\n* \$", range( 1, count( $messages ) ) ) );
66 $message->params( $messages )->parse();
67 }
68
69 parent::__construct( 'blockedtitle', $message );
70 }
71}
72
74class_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:45
Interface for objects representing user identity.