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