MediaWiki master
MediaWiki\Block\BlockTarget Class Reference

Base class for block targets. More...

Inherits MediaWiki\DAO\WikiAwareEntity, and Stringable.

Inherited by MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

Collaboration diagram for MediaWiki\Block\BlockTarget:

Public Member Functions

 __toString ()
 
 equals (?BlockTarget $other)
 Compare this object with another one.
 
 getLegacyTuple ()
 Get the target and type tuple conventionally returned by BlockUtils::parseBlockTarget()
 
 getLogPage ()
 Get the title to be used when logging an action on this block.
 
 getSpecificity ()
 Get the score of this block for purposes of choosing a more specific block, where lower is more specific.
 
 getType ()
 Get one of the Block::TYPE_xxx constants associated with this target.
 
 getWikiId ()
 Get the ID of the wiki this page belongs to.
Returns
string|false The wiki's logical name, or self::LOCAL to indicate the local wiki.

 
 toString ()
 Get the username, the IP address, range, or autoblock ID prefixed with a "#".
 
 validateForCreation ()
 Check the target data against more stringent requirements imposed when a block is created from user input.
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Protected Member Functions

 __construct (string|false $wikiId)
 
 getLegacyUnion ()
 Get the first part of the legacy tuple.
 

Protected Attributes

string false $wikiId
 

Detailed Description

Base class for block targets.

Since
1.44

Definition at line 17 of file BlockTarget.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockTarget::__construct ( string|false $wikiId)
protected
Parameters
string | false$wikiIdUserIdentity and Block extend WikiAwareEntity and so we must ask for a wiki ID as well, to forward it through, even though we don't use it.

Definition at line 27 of file BlockTarget.php.

References MediaWiki\Block\BlockTarget\$wikiId.

Member Function Documentation

◆ __toString()

MediaWiki\Block\BlockTarget::__toString ( )

Definition at line 36 of file BlockTarget.php.

References MediaWiki\Block\BlockTarget\toString().

◆ equals()

MediaWiki\Block\BlockTarget::equals ( ?BlockTarget $other)

Compare this object with another one.

Parameters
BlockTarget | null$other
Returns
bool

Definition at line 46 of file BlockTarget.php.

References MediaWiki\Block\BlockTarget\toString().

Referenced by MediaWiki\Block\BlockPermissionChecker\checkBlockPermissions().

◆ getLegacyTuple()

MediaWiki\Block\BlockTarget::getLegacyTuple ( )

Get the target and type tuple conventionally returned by BlockUtils::parseBlockTarget()

Returns
array

Definition at line 98 of file BlockTarget.php.

◆ getLegacyUnion()

MediaWiki\Block\BlockTarget::getLegacyUnion ( )
abstractprotected

Get the first part of the legacy tuple.

Returns
UserIdentity|string

Reimplemented in MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

◆ getLogPage()

MediaWiki\Block\BlockTarget::getLogPage ( )
abstract

Get the title to be used when logging an action on this block.

For an autoblock, the title is technically invalid, with a hash character in the DB key. For a range block, the title is valid but is not a user page for a specific user.

See also getUserPage(), which exists only for subclasses which relate to a specific user with a talk page.

Returns
PageReference

Reimplemented in MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

◆ getSpecificity()

MediaWiki\Block\BlockTarget::getSpecificity ( )
abstract

Get the score of this block for purposes of choosing a more specific block, where lower is more specific.

  • 1: user block
  • 2: single IP block
  • 2-3: range block scaled according to the size of the range
Returns
float|int

Reimplemented in MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

◆ getType()

MediaWiki\Block\BlockTarget::getType ( )
abstract

Get one of the Block::TYPE_xxx constants associated with this target.

Returns
int

Reimplemented in MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

◆ getWikiId()

MediaWiki\Block\BlockTarget::getWikiId ( )

Get the ID of the wiki this page belongs to.

Returns
string|false The wiki's logical name, or self::LOCAL to indicate the local wiki.

Implements MediaWiki\DAO\WikiAwareEntity.

Definition at line 32 of file BlockTarget.php.

References MediaWiki\Block\BlockTarget\$wikiId.

◆ toString()

MediaWiki\Block\BlockTarget::toString ( )
abstract

Get the username, the IP address, range, or autoblock ID prefixed with a "#".

Such a string will round-trip through BlockTarget::newFromString(), giving back the same target.

Returns
string

Reimplemented in MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

Referenced by MediaWiki\Block\BlockTarget\__toString(), and MediaWiki\Block\BlockTarget\equals().

◆ validateForCreation()

MediaWiki\Block\BlockTarget::validateForCreation ( )
abstract

Check the target data against more stringent requirements imposed when a block is created from user input.

This is in addition to the loose validation done by BlockTargetFactory::newFromString().

Returns
StatusValue

Reimplemented in MediaWiki\Block\AnonIpBlockTarget, MediaWiki\Block\AutoBlockTarget, MediaWiki\Block\RangeBlockTarget, and MediaWiki\Block\UserBlockTarget.

Member Data Documentation

◆ $wikiId


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