MediaWiki master
MediaWiki\Block\BlockTargetFactory Class Reference

Factory for BlockTarget objects. More...

Inherits MediaWiki\DAO\WikiAwareEntity.

Collaboration diagram for MediaWiki\Block\BlockTargetFactory:

Public Member Functions

 __construct (ServiceOptions $options, UserIdentityLookup $userIdentityLookup, UserNameUtils $userNameUtils, string|false $wikiId=Block::LOCAL)
 
 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.

 
 newAnonIpBlockTarget (string $ip)
 Create an IP block target.
 
 newAutoBlockTarget (int $id)
 Create an AutoBlockTarget for the given ID.
 
 newFromIp (string $ip)
 Try to create a block target from a single IP address.
 
 newFromLegacyUnion ( $union)
 Try to create a BlockTarget from a UserIdentity|string|null, a union type previously used as a target by various methods.
 
 newFromRowRaw ( $row)
 Try to create a BlockTarget from a row which must contain bt_user, bt_address and optionally bt_user_text.
 
 newFromRowRedacted ( $row)
 Try to create a BlockTarget from a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text.
 
 newFromString (?string $str)
 Try to create a block target from a user input string.
 
 newFromUser (UserIdentity $user)
 Create a BlockTarget from a UserIdentity, which may refer to a registered user, an IP address or range.
 
 newRangeBlockTarget (string $cidr)
 Create a range block target.
 
 newUserBlockTarget (UserIdentity $user)
 Create a UserBlockTarget for the given user.
 
- Public Member Functions inherited from MediaWiki\DAO\WikiAwareEntity
 assertWiki ( $wikiId)
 Throws if $wikiId is different from the return value of getWikiId().
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 
- Public Attributes inherited from MediaWiki\DAO\WikiAwareEntity
const LOCAL = false
 Wiki ID value to use with instances that are defined relative to the local wiki.
 

Detailed Description

Factory for BlockTarget objects.

Since
1.44

Definition at line 24 of file BlockTargetFactory.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockTargetFactory::__construct ( ServiceOptions $options,
UserIdentityLookup $userIdentityLookup,
UserNameUtils $userNameUtils,
string|false $wikiId = Block::LOCAL )

Member Function Documentation

◆ getWikiId()

MediaWiki\Block\BlockTargetFactory::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 58 of file BlockTargetFactory.php.

◆ newAnonIpBlockTarget()

MediaWiki\Block\BlockTargetFactory::newAnonIpBlockTarget ( string $ip)

Create an IP block target.

A simple constructor proxy for pre-validated input. Use newFromIP() to apply normalization, for example stripping leading zeroes.

Parameters
string$ip
Returns
AnonIpBlockTarget

Definition at line 267 of file BlockTargetFactory.php.

◆ newAutoBlockTarget()

MediaWiki\Block\BlockTargetFactory::newAutoBlockTarget ( int $id)

Create an AutoBlockTarget for the given ID.

A simple constructor proxy for pre-validated input.

Parameters
int$id
Returns
AutoBlockTarget

Definition at line 235 of file BlockTargetFactory.php.

◆ newFromIp()

MediaWiki\Block\BlockTargetFactory::newFromIp ( string $ip)

Try to create a block target from a single IP address.

Parameters
string$ip
Returns
AnonIpBlockTarget|null

Definition at line 115 of file BlockTargetFactory.php.

◆ newFromLegacyUnion()

MediaWiki\Block\BlockTargetFactory::newFromLegacyUnion ( $union)

Try to create a BlockTarget from a UserIdentity|string|null, a union type previously used as a target by various methods.

Parameters
UserIdentity | string | null$union
Returns
BlockTarget|null

Definition at line 151 of file BlockTargetFactory.php.

◆ newFromRowRaw()

MediaWiki\Block\BlockTargetFactory::newFromRowRaw ( $row)

Try to create a BlockTarget from a row which must contain bt_user, bt_address and optionally bt_user_text.

bt_auto is ignored, so this is suitable for permissions and for block creation but not for display.

Parameters
stdClass$row
Returns
BlockTarget|null

Definition at line 175 of file BlockTargetFactory.php.

◆ newFromRowRedacted()

MediaWiki\Block\BlockTargetFactory::newFromRowRedacted ( $row)

Try to create a BlockTarget from a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text.

If bt_auto is set, the address will be redacted to avoid disclosing it. The ID will be wrapped in an AutoblockTarget.

Parameters
stdClass$row
Returns
BlockTarget|null

Definition at line 189 of file BlockTargetFactory.php.

◆ newFromString()

MediaWiki\Block\BlockTargetFactory::newFromString ( ?string $str)

Try to create a block target from a user input string.

Parameters
string | null$str
Returns
BlockTarget|null

Definition at line 68 of file BlockTargetFactory.php.

◆ newFromUser()

MediaWiki\Block\BlockTargetFactory::newFromUser ( UserIdentity $user)

Create a BlockTarget from a UserIdentity, which may refer to a registered user, an IP address or range.

Parameters
UserIdentity$user
Returns
BlockTarget

Definition at line 129 of file BlockTargetFactory.php.

◆ newRangeBlockTarget()

MediaWiki\Block\BlockTargetFactory::newRangeBlockTarget ( string $cidr)

Create a range block target.

A simple constructor proxy for pre-validated input.

Parameters
string$cidr
Returns
RangeBlockTarget

Definition at line 282 of file BlockTargetFactory.php.

◆ newUserBlockTarget()

MediaWiki\Block\BlockTargetFactory::newUserBlockTarget ( UserIdentity $user)

Create a UserBlockTarget for the given user.

A simple constructor proxy for pre-validated input.

The user must be a real registered user. Use newFromUser() to create a block target from a UserIdentity which may represent an IP address.

Parameters
UserIdentity$user
Returns
UserBlockTarget

Definition at line 250 of file BlockTargetFactory.php.

Member Data Documentation

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Block\BlockTargetFactory::CONSTRUCTOR_OPTIONS
Initial value:
= [
]
const BlockCIDRLimit
Name constant for the BlockCIDRLimit setting, for use with Config::get()
Access: internal
Only for use by ServiceWiring

Definition at line 40 of file BlockTargetFactory.php.


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