MediaWiki master
MediaWiki\Block\BlockUtils Class Reference

Backend class for blocking utils. More...

Public Member Functions

 __construct (BlockTargetFactory $blockTargetFactory)
 
 parseBlockTarget ( $target)
 From string specification or UserIdentity, get the block target and the type of target.
 
 parseBlockTargetRow ( $row)
 From a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text, determine the block target and type.
 
 validateTarget ( $value)
 Validate block target.
 

Detailed Description

Backend class for blocking utils.

This service should contain any methods that are useful to more than one blocking-related class and don't fit any other service.

For now, this includes only

  • block target parsing
  • block target validation
  • parsing the target and type of a block in the database

    Deprecated
    since 1.44 use BlockTargetFactory
    Since
    1.36

Definition at line 42 of file BlockUtils.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockUtils::__construct ( BlockTargetFactory $blockTargetFactory)

Definition at line 45 of file BlockUtils.php.

Member Function Documentation

◆ parseBlockTarget()

MediaWiki\Block\BlockUtils::parseBlockTarget ( $target)

From string specification or UserIdentity, get the block target and the type of target.

Note that, except for null, it is always safe to treat the target as a string; for UserIdentityValue objects this will return UserIdentityValue::__toString() which in turn gives UserIdentityValue::getName().

If the type is not null, it will be an AbstractBlock::TYPE_ constant.

Since 1.42, it is no longer safe to pass a value from the database field ipb_address/bt_address to this method, since the username is normalized. Use parseBlockTargetRow() instead. (T346683)

Parameters
string | UserIdentity | null$target
Returns
array [ UserIdentity|String|null, int|null ]

Definition at line 67 of file BlockUtils.php.

◆ parseBlockTargetRow()

MediaWiki\Block\BlockUtils::parseBlockTargetRow ( $row)

From a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text, determine the block target and type.

Since
1.42
Parameters
\\stdClass$row
Returns
array [ UserIdentity|String|null, int|null ]

Definition at line 84 of file BlockUtils.php.

◆ validateTarget()

MediaWiki\Block\BlockUtils::validateTarget ( $value)

Validate block target.

Parameters
string | UserIdentity$value
Returns
Status

Definition at line 100 of file BlockUtils.php.


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