MediaWiki REL1_37
MediaWiki\Block\BlockErrorFormatter Class Reference

A service class for getting formatted information about a block. More...

Collaboration diagram for MediaWiki\Block\BlockErrorFormatter:

Public Member Functions

 __construct (TitleFormatter $titleFormatter)
 
 getMessage (Block $block, UserIdentity $user, Language $language, $ip)
 Get a block error message.
 

Private Member Functions

 formatBlockerLink (?UserIdentity $blocker, Language $language)
 Create a link to the blocker's user page.
 
 formatBlockReason (CommentStoreComment $reason, Language $language)
 Format the block reason as plain wikitext in the specified language.
 
 getBlockErrorInfo (Block $block)
 Get a standard set of block details for building a block error message.
 
 getBlockErrorMessageKey (Block $block)
 Determine the block error message key by examining the block.
 
 getBlockErrorMessageParams (Block $block, UserIdentity $user, Language $language, $ip)
 Get the formatted parameters needed to build the block error messages handled by getBlockErrorMessageKey.
 
 getFormattedBlockErrorInfo (Block $block, UserIdentity $user, Language $language)
 Get a standard set of block details for building a block error message, formatted for a specified user and language.
 

Private Attributes

TitleFormatter $titleFormatter
 

Detailed Description

A service class for getting formatted information about a block.

To obtain an instance, use MediaWikiServices::getInstance()->getBlockErrorFormatter().

Since
1.35

Definition at line 36 of file BlockErrorFormatter.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockErrorFormatter::__construct ( TitleFormatter  $titleFormatter)
Parameters
TitleFormatter$titleFormatter

Definition at line 44 of file BlockErrorFormatter.php.

References MediaWiki\Block\BlockErrorFormatter\$titleFormatter.

Member Function Documentation

◆ formatBlockerLink()

MediaWiki\Block\BlockErrorFormatter::formatBlockerLink ( ?UserIdentity  $blocker,
Language  $language 
)
private

Create a link to the blocker's user page.

This must be done here rather than in the message translation, because the blocker may not be a local user, in which case their page cannot be linked.

Parameters
?UserIdentity$blocker
Language$language
Returns
string Link to the blocker's page; blocker's name if not a local user

Definition at line 147 of file BlockErrorFormatter.php.

References Language\embedBidi(), MediaWiki\User\UserIdentity\getId(), MediaWiki\User\UserIdentity\getName(), and NS_USER.

Referenced by MediaWiki\Block\BlockErrorFormatter\getBlockErrorMessageParams().

◆ formatBlockReason()

MediaWiki\Block\BlockErrorFormatter::formatBlockReason ( CommentStoreComment  $reason,
Language  $language 
)
private

Format the block reason as plain wikitext in the specified language.

Parameters
CommentStoreComment$reason
Language$language
Returns
string

Definition at line 130 of file BlockErrorFormatter.php.

Referenced by MediaWiki\Block\BlockErrorFormatter\getFormattedBlockErrorInfo().

◆ getBlockErrorInfo()

MediaWiki\Block\BlockErrorFormatter::getBlockErrorInfo ( Block  $block)
private

Get a standard set of block details for building a block error message.

Parameters
Block$block
Returns
mixed[]
  • identifier: Information for looking up the block
  • targetName: The target, as a string
  • blockerName: The blocker, as a string
  • reason: Reason for the block
  • expiry: Expiry time
  • timestamp: Time the block was created

Definition at line 84 of file BlockErrorFormatter.php.

References MediaWiki\Block\Block\getBlocker(), MediaWiki\Block\Block\getExpiry(), MediaWiki\Block\Block\getIdentifier(), MediaWiki\Block\Block\getReasonComment(), MediaWiki\Block\Block\getTargetName(), and MediaWiki\Block\Block\getTimestamp().

Referenced by MediaWiki\Block\BlockErrorFormatter\getFormattedBlockErrorInfo().

◆ getBlockErrorMessageKey()

MediaWiki\Block\BlockErrorFormatter::getBlockErrorMessageKey ( Block  $block)
private

Determine the block error message key by examining the block.

Parameters
Block$block
Returns
string Message key

Definition at line 176 of file BlockErrorFormatter.php.

References MediaWiki\Block\Block\getType(), MediaWiki\Block\Block\isSitewide(), and MediaWiki\Block\Block\TYPE_AUTO.

Referenced by MediaWiki\Block\BlockErrorFormatter\getMessage().

◆ getBlockErrorMessageParams()

MediaWiki\Block\BlockErrorFormatter::getBlockErrorMessageParams ( Block  $block,
UserIdentity  $user,
Language  $language,
  $ip 
)
private

Get the formatted parameters needed to build the block error messages handled by getBlockErrorMessageKey.

Parameters
Block$block
UserIdentity$user
Language$language
string$ip
Returns
mixed[] Params used by standard block error messages, in order:
  • blockerLink: Link to the blocker's user page, if any; otherwise same as blockerName
  • reason: Reason for the block
  • ip: IP address of the user attempting to perform an action
  • blockerName: The blocker, as a bidi-embedded string
  • identifier: Information for looking up the block
  • expiry: Expiry time, in the specified language
  • targetName: The target, as a bidi-embedded string
  • timestamp: Time the block was created, in the specified language

Definition at line 210 of file BlockErrorFormatter.php.

References Language\commaList(), MediaWiki\Block\BlockErrorFormatter\formatBlockerLink(), MediaWiki\Block\Block\getBlocker(), and MediaWiki\Block\BlockErrorFormatter\getFormattedBlockErrorInfo().

Referenced by MediaWiki\Block\BlockErrorFormatter\getMessage().

◆ getFormattedBlockErrorInfo()

MediaWiki\Block\BlockErrorFormatter::getFormattedBlockErrorInfo ( Block  $block,
UserIdentity  $user,
Language  $language 
)
private

Get a standard set of block details for building a block error message, formatted for a specified user and language.

Since
1.35
Parameters
Block$block
UserIdentity$user
Language$language
Returns
mixed[] See getBlockErrorInfo

Definition at line 106 of file BlockErrorFormatter.php.

References Language\embedBidi(), MediaWiki\Block\BlockErrorFormatter\formatBlockReason(), Language\formatExpiry(), MediaWiki\Block\BlockErrorFormatter\getBlockErrorInfo(), and Language\userTimeAndDate().

Referenced by MediaWiki\Block\BlockErrorFormatter\getBlockErrorMessageParams().

◆ getMessage()

MediaWiki\Block\BlockErrorFormatter::getMessage ( Block  $block,
UserIdentity  $user,
Language  $language,
  $ip 
)

Get a block error message.

Different message keys are chosen depending on the block features. Message parameters are formatted for the specified user and language.

Parameters
Block$block
UserIdentity$user
Language$language
string$ip
Returns
Message

Definition at line 61 of file BlockErrorFormatter.php.

References MediaWiki\Block\BlockErrorFormatter\getBlockErrorMessageKey(), and MediaWiki\Block\BlockErrorFormatter\getBlockErrorMessageParams().

Member Data Documentation

◆ $titleFormatter

TitleFormatter MediaWiki\Block\BlockErrorFormatter::$titleFormatter
private

The documentation for this class was generated from the following file: