MediaWiki REL1_35
MediaWiki\Block\BlockErrorFormatter Class Reference

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

Public Member Functions

 getMessage (AbstractBlock $block, User $user, Language $language, $ip)
 Get a block error message.
 

Private Member Functions

 formatBlockerLink ( $blockerName, $blockerId, 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 (AbstractBlock $block)
 Get a standard set of block details for building a block error message.
 
 getBlockErrorMessageKey (AbstractBlock $block)
 Determine the block error message key by examining the block.
 
 getBlockErrorMessageParams (AbstractBlock $block, User $user, Language $language, $ip)
 Get the formatted parameters needed to build the block error messages handled by getBlockErrorMessageKey.
 
 getFormattedBlockErrorInfo (AbstractBlock $block, User $user, Language $language)
 Get a standard set of block details for building a block error message, formatted for a specified user and language.
 

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 34 of file BlockErrorFormatter.php.

Member Function Documentation

◆ formatBlockerLink()

MediaWiki\Block\BlockErrorFormatter::formatBlockerLink (   $blockerName,
  $blockerId,
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
string$blockerNameFormatted blocker name
int$blockerId
Language$language
Returns
string Link to the blocker's page; blocker's name if not a local user

Definition at line 134 of file BlockErrorFormatter.php.

References Language\embedBidi(), and User\newFromId().

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 116 of file BlockErrorFormatter.php.

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

◆ getBlockErrorInfo()

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

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

Parameters
AbstractBlock$block
Returns
mixed[]
  • identifier: Information for looking up the block
  • targetName: The target, as a string
  • blockerName: The blocker, as a string
  • blockerId: ID of the blocker; 0 if a foreign user
  • reason: Reason for the block
  • expiry: Expiry time
  • timestamp: Time the block was created

Definition at line 70 of file BlockErrorFormatter.php.

References MediaWiki\Block\AbstractBlock\getBy(), MediaWiki\Block\AbstractBlock\getByName(), MediaWiki\Block\AbstractBlock\getExpiry(), MediaWiki\Block\AbstractBlock\getIdentifier(), MediaWiki\Block\AbstractBlock\getReasonComment(), MediaWiki\Block\AbstractBlock\getTarget(), and MediaWiki\Block\AbstractBlock\getTimestamp().

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

◆ getBlockErrorMessageKey()

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

Determine the block error message key by examining the block.

Parameters
AbstractBlock$block
Returns
string Message key

Definition at line 152 of file BlockErrorFormatter.php.

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

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

◆ getBlockErrorMessageParams()

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

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

Parameters
AbstractBlock$block
User$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 186 of file BlockErrorFormatter.php.

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

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

◆ getFormattedBlockErrorInfo()

MediaWiki\Block\BlockErrorFormatter::getFormattedBlockErrorInfo ( AbstractBlock  $block,
User  $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
AbstractBlock$block
User$user
Language$language
Returns
mixed[] See getBlockErrorInfo

Definition at line 92 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 ( AbstractBlock  $block,
User  $user,
Language  $language,
  $ip 
)

Get a block error message.

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

Parameters
AbstractBlock$block
User$user
Language$language
string$ip
Returns
Message

Definition at line 46 of file BlockErrorFormatter.php.

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


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