MediaWiki  master
ApiBlockInfoTrait.php
Go to the documentation of this file.
1 <?php
23 
28 
43  private function getBlockDetails(
44  Block $block,
45  $language = null
46  ) {
47  if ( $language === null ) {
48  $language = $this->getLanguage();
49  }
50 
51  $blocker = $block->getBlocker();
52 
53  $vals = [];
54  $vals['blockid'] = $block->getId();
55  $vals['blockedby'] = $blocker ? $blocker->getName() : '';
56  $vals['blockedbyid'] = $blocker ? $blocker->getId() : 0;
57  $vals['blockreason'] = $block->getReasonComment()
58  ->message->inLanguage( $language )->plain();
59  $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
60  $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
61  $vals['blockpartial'] = !$block->isSitewide();
62  $vals['blocknocreate'] = $block->isCreateAccountBlocked();
63  $vals['blockanononly'] = !$block->isHardblock();
64 
65  if ( $block instanceof SystemBlock ) {
66  $vals['systemblocktype'] = $block->getSystemBlockType();
67  }
68 
69  return $vals;
70  }
71 
72  // region Methods required from ApiBase
81  abstract public function getLanguage();
82 
84  // endregion -- end of methods required from ApiBase
85 
86 }
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1668
MediaWiki\Block\Block\getBlocker
getBlocker()
Get the user who applied this block.
MediaWiki\Block\Block\isSitewide
isSitewide()
Indicates that the block is a sitewide block.
ApiBlockInfoTrait
trait ApiBlockInfoTrait
Definition: ApiBlockInfoTrait.php:27
MediaWiki\Block\Block
Represents a block that may prevent users from performing specific operations.
Definition: Block.php:37
MediaWiki\Block\Block\isHardblock
isHardblock()
Returns whether the block is a hardblock (affects logged-in users on a given IP/range)
MediaWiki\Block\Block\getId
getId()
Get the block ID.
MediaWiki\Block\SystemBlock
System blocks are temporary blocks that are created on enforcement (e.g.
Definition: SystemBlock.php:35
MediaWiki\Block\Block\isCreateAccountBlocked
isCreateAccountBlocked()
Get the flag indicating whether this block blocks the target from creating an account.
MediaWiki\Block\Block\getTimestamp
getTimestamp()
Get the timestamp indicating when the block was created.
MediaWiki\Block\Block\getExpiry
getExpiry()
Get the block expiry time.
ApiResult\formatExpiry
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
Definition: ApiResult.php:1194
MediaWiki\Block\Block\getReasonComment
getReasonComment()
Get the reason for creating the block.