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, bool $canSeeHiddenBlocks=false)
 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 26 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 120 of file ApiBlockInfoHelper.php.

References if.

◆ getBlockDetails()

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

Get basic info about a given block.

Parameters
Block$block
Language$language
UserIdentity$user
bool$canSeeHiddenBlocksWhether the viewer has the hideuser right (since 1.47). Set this only after you check the right.
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
  • blockhidden - true if the block is hidden, omitted if the block is not hidden or the viewer may not see hidden blocks
  • blockcomponents - If the block is a composite block, this will be an array of block info arrays

Definition at line 53 of file ApiBlockInfoHelper.php.

References MediaWiki\Api\ApiResult\formatExpiry(), MediaWiki\Language\Language\formatExpiry(), 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\isEmailBlocked(), MediaWiki\Block\Block\isHardblock(), MediaWiki\Block\Block\isSitewide(), and wfTimestamp().

Referenced by getBlockDetails().


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