MediaWiki  master
ApiBlockInfoTrait.php
Go to the documentation of this file.
1 <?php
23 
28 
43  private function getBlockDetails(
44  AbstractBlock $block,
45  $language = null
46  ) {
47  if ( $language === null ) {
48  $language = $this->getLanguage();
49  }
50 
51  $vals = [];
52  $vals['blockid'] = $block->getId();
53  $vals['blockedby'] = $block->getByName();
54  $vals['blockedbyid'] = $block->getBy();
55  $vals['blockreason'] = $block->getReasonComment()
56  ->message->inLanguage( $language )->plain();
57  $vals['blockedtimestamp'] = wfTimestamp( TS_ISO_8601, $block->getTimestamp() );
58  $vals['blockexpiry'] = ApiResult::formatExpiry( $block->getExpiry(), 'infinite' );
59  $vals['blockpartial'] = !$block->isSitewide();
60  if ( $block instanceof SystemBlock ) {
61  $vals['systemblocktype'] = $block->getSystemBlockType();
62  }
63  return $vals;
64  }
65 
75  abstract public function getLanguage();
76 
79 }
MediaWiki\Block\AbstractBlock\getBy
getBy()
Get the user id of the blocking sysop.
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:1808
MediaWiki\Block\AbstractBlock\getId
getId()
Get the block ID.
Definition: AbstractBlock.php:138
MediaWiki\Block\AbstractBlock\getReasonComment
getReasonComment()
Get the reason for creating the block.
Definition: AbstractBlock.php:172
MediaWiki\Block\AbstractBlock\isSitewide
isSitewide( $x=null)
Indicates that the block is a sitewide block.
Definition: AbstractBlock.php:215
ApiBlockInfoTrait
trait ApiBlockInfoTrait
Definition: ApiBlockInfoTrait.php:27
MediaWiki\Block\SystemBlock
System blocks are temporary blocks that are created on enforcement (e.g.
Definition: SystemBlock.php:33
MediaWiki\Block\AbstractBlock\getExpiry
getExpiry()
Get the block expiry time.
Definition: AbstractBlock.php:469
MediaWiki\Block\AbstractBlock\getTimestamp
getTimestamp()
Get the timestamp indicating when the block was created.
Definition: AbstractBlock.php:489
ApiResult\formatExpiry
static formatExpiry( $expiry, $infinity='infinity')
Format an expiry timestamp for API output.
Definition: ApiResult.php:1193
MediaWiki\Block\AbstractBlock
Definition: AbstractBlock.php:38
MediaWiki\Block\AbstractBlock\getByName
getByName()
Get the username of the blocking sysop.