MediaWiki master
MediaWiki\Api\ApiBlockInfoHelper Class Reference

Helper class for API modules that display block information. More...

Public Member Functions

 getBlockCode (Block $block)
 Get the API error code, to be used in ApiMessage::create or ApiBase::dieWithError.
 
 getBlockDetails (Block $block, Language $language, UserIdentity $user)
 Get basic info about a given block.
 

Detailed Description

Helper class for API modules that display block information.

Intended for use via composition.

Since
1.44

Definition at line 39 of file ApiBlockInfoHelper.php.

Member Function Documentation

◆ getBlockCode()

MediaWiki\Api\ApiBlockInfoHelper::getBlockCode ( Block $block)

Get the API error code, to be used in ApiMessage::create or ApiBase::dieWithError.

Parameters
Block$block
Returns
string

Definition at line 116 of file ApiBlockInfoHelper.php.

◆ getBlockDetails()

MediaWiki\Api\ApiBlockInfoHelper::getBlockDetails ( Block $block,
Language $language,
UserIdentity $user )

Get basic info about a given block.

Returns
array Array containing several keys:
  • blockid - ID of the block
  • blockedby - username of the blocker
  • blockedbyid - user ID of the blocker
  • blockreason - reason provided for the block
  • blockedtimestamp - timestamp for when the block was placed/modified
  • blockedtimestampformatted - blockedtimestamp, formatted for the current locale
  • blockexpiry - expiry time of the block
  • blockexpiryformatted - blockexpiry formatted for the current locale, omitted if infinite
  • blockexpiryrelative - relative time to blockexpiry (e.g. 'in 5 days'), omitted if infinite
  • blockpartial - block only applies to certain pages, namespaces and/or actions
  • systemblocktype - system block type, if any
  • blockcomponents - If the block is a composite block, this will be an array of block info arrays

Definition at line 59 of file ApiBlockInfoHelper.php.

References MediaWiki\Language\Language\formatExpiry(), MediaWiki\Api\ApiResult\formatExpiry(), MediaWiki\Api\ApiBlockInfoHelper\getBlockDetails(), MediaWiki\Block\Block\getBlocker(), MediaWiki\Block\Block\getExpiry(), MediaWiki\Language\Language\getHumanTimestamp(), MediaWiki\Block\Block\getId(), MediaWiki\Block\Block\getReasonComment(), MediaWiki\Block\Block\getTimestamp(), MediaWiki\Block\Block\isCreateAccountBlocked(), MediaWiki\Block\Block\isHardblock(), MediaWiki\Block\Block\isSitewide(), and wfTimestamp().

Referenced by MediaWiki\Api\ApiBlockInfoHelper\getBlockDetails().


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