MediaWiki  master
MediaWiki\Block\Block Interface Reference

Represents a block that may prevent users from performing specific operations. More...

Inheritance diagram for MediaWiki\Block\Block:

Public Member Functions

 getBlocker ()
 Get the user who applied this block. More...
 
 getExpiry ()
 Get the block expiry time. More...
 
 getId ()
 Get the block ID. More...
 
 getIdentifier ()
 Get the information that identifies this block, such that a user could look up everything that can be found about this block. More...
 
 getReasonComment ()
 Get the reason for creating the block. More...
 
 getTargetName ()
 Return the name of the block target as a string. More...
 
 getTargetUserIdentity ()
 Get the UserIdentity identifying the blocked user, if the target is indeed a user (that is, if getType() returns TYPE_USER). More...
 
 getTimestamp ()
 Get the timestamp indicating when the block was created. More...
 
 getType ()
 Get the type of target for this particular block. More...
 
 isBlocking ( $target)
 Determines whether this block is blocking the given target (and only that target). More...
 
 isCreateAccountBlocked ()
 Get the flag indicating whether this block blocks the target from creating an account. More...
 
 isHardblock ()
 Returns whether the block is a hardblock (affects logged-in users on a given IP/range) More...
 
 isSitewide ()
 Indicates that the block is a sitewide block. More...
 

Public Attributes

const TYPE_AUTO = 4
 
const TYPE_ID = 5
 
const TYPE_IP = 2
 
const TYPE_RANGE = 3
 
const TYPE_USER = 1
 

Detailed Description

Represents a block that may prevent users from performing specific operations.

The block may apply to a specific user, to a network address, network range, or some other aspect of a web request. The block may apply to the entire site, or may be limited to specific pages or namespaces.

Since
1.37 Extracted from the AbstractBlock base class, which was in turn factored out of DatabaseBlock in 1.34.

Definition at line 37 of file Block.php.

Member Function Documentation

◆ getBlocker()

MediaWiki\Block\Block::getBlocker ( )

Get the user who applied this block.

Returns
UserIdentity|null user identity or null. May be an external user.

Implemented in MediaWiki\Block\SystemBlock, MediaWiki\Block\DatabaseBlock, and MediaWiki\Block\CompositeBlock.

Referenced by MediaWiki\Block\BlockErrorFormatter\getBlockErrorInfo(), and MediaWiki\Block\BlockErrorFormatter\getBlockErrorMessageParams().

◆ getExpiry()

MediaWiki\Block\Block::getExpiry ( )

Get the block expiry time.

Returns
string

Implemented in MediaWiki\Block\CompositeBlock, and MediaWiki\Block\AbstractBlock.

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

◆ getId()

MediaWiki\Block\Block::getId ( )

Get the block ID.

Returns
?int

Implemented in MediaWiki\Block\DatabaseBlock, and MediaWiki\Block\AbstractBlock.

◆ getIdentifier()

MediaWiki\Block\Block::getIdentifier ( )

Get the information that identifies this block, such that a user could look up everything that can be found about this block.

Typically a scalar ID (integer or string), but can also return a list of IDs, or an associative array encoding a composite ID. Must be safe to serialize as JSON.

Returns
mixed Identifying information

Implemented in MediaWiki\Block\SystemBlock, MediaWiki\Block\DatabaseBlock, and MediaWiki\Block\CompositeBlock.

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

◆ getReasonComment()

MediaWiki\Block\Block::getReasonComment ( )

Get the reason for creating the block.

Returns
CommentStoreComment

Implemented in MediaWiki\Block\AbstractBlock.

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

◆ getTargetName()

MediaWiki\Block\Block::getTargetName ( )

Return the name of the block target as a string.

Depending on the type returned by get Type(), this could be a user name, an IP address or range, an internal ID, etc.

Returns
string

Implemented in MediaWiki\Block\AbstractBlock.

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

◆ getTargetUserIdentity()

MediaWiki\Block\Block::getTargetUserIdentity ( )

Get the UserIdentity identifying the blocked user, if the target is indeed a user (that is, if getType() returns TYPE_USER).

Returns
?UserIdentity

Implemented in MediaWiki\Block\AbstractBlock.

◆ getTimestamp()

MediaWiki\Block\Block::getTimestamp ( )

Get the timestamp indicating when the block was created.

Returns
string

Implemented in MediaWiki\Block\AbstractBlock.

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

◆ getType()

MediaWiki\Block\Block::getType ( )

Get the type of target for this particular block.

Returns
int|null Block::TYPE_ constant, will never be TYPE_ID

Implemented in MediaWiki\Block\DatabaseBlock, and MediaWiki\Block\AbstractBlock.

Referenced by ApiBase\dieBlocked(), and MediaWiki\Block\BlockErrorFormatter\getBlockErrorMessageKey().

◆ isBlocking()

MediaWiki\Block\Block::isBlocking (   $target)

Determines whether this block is blocking the given target (and only that target).

Parameters
UserIdentity | string$target
Returns
bool

Implemented in MediaWiki\Block\AbstractBlock.

◆ isCreateAccountBlocked()

MediaWiki\Block\Block::isCreateAccountBlocked ( )

◆ isHardblock()

MediaWiki\Block\Block::isHardblock ( )

Returns whether the block is a hardblock (affects logged-in users on a given IP/range)

Note that users are always hardblocked, since they're logged in by definition.

Returns
bool

Referenced by MediaWiki\Block\AbstractBlock\__construct(), MediaWiki\Block\CompositeBlock\__construct(), MediaWiki\Block\DatabaseBlock\initFromRow(), MediaWiki\Block\AbstractBlock\isHardblock(), and MediaWiki\Block\DatabaseBlock\isHardblock().

◆ isSitewide()

Member Data Documentation

◆ TYPE_AUTO

◆ TYPE_ID

const MediaWiki\Block\Block::TYPE_ID = 5

Definition at line 45 of file Block.php.

◆ TYPE_IP

◆ TYPE_RANGE

◆ TYPE_USER


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