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, $wikiId=Block::LOCAL)
 
 getWikiId ()
 Get the ID of the wiki this page belongs to.
 
 newAnonIpBlockTarget (string $ip)
 Create an IP block target.
 
 newAutoBlockTarget (int $id)
 Create an AutoBlockTarget for the given ID.
 
 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
 

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

Definition at line 51 of file BlockTargetFactory.php.

References MediaWiki\Config\ServiceOptions\assertRequiredOptions(), MediaWiki\MainConfigNames\BlockCIDRLimit, and MediaWiki\Config\ServiceOptions\get().

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 64 of file BlockTargetFactory.php.

◆ newAnonIpBlockTarget()

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

Create an IP block target.

A simple constructor proxy for pre-validated input.

Parameters
string$ip
Returns
AnonIpBlockTarget

Definition at line 259 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 228 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 144 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 168 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 182 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 74 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 122 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 274 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 243 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 41 of file BlockTargetFactory.php.


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