MediaWiki  master
MediaWiki\Block\BlockUtils Class Reference

Backend class for blocking utils. More...

Collaboration diagram for MediaWiki\Block\BlockUtils:

Public Member Functions

 __construct (ServiceOptions $options, UserFactory $userFactory)
 
 parseBlockTarget ( $target)
 From an existing block, get the target and the type of target. More...
 
 validateTarget ( $value)
 Validate block target. More...
 

Public Attributes

const CONSTRUCTOR_OPTIONS
 

Private Member Functions

 validateIPv4Range (int $range)
 Validate an IPv4 range. More...
 
 validateIPv6Range (int $range)
 Validate an IPv6 range. More...
 

Private Attributes

ServiceOptions $options
 
UserFactory $userFactory
 

Detailed Description

Backend class for blocking utils.

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

For now, this includes only

  • block target parsing
  • block target validation
Since
1.36

Definition at line 44 of file BlockUtils.php.

Constructor & Destructor Documentation

◆ __construct()

MediaWiki\Block\BlockUtils::__construct ( ServiceOptions  $options,
UserFactory  $userFactory 
)
Parameters
ServiceOptions$options
UserFactory$userFactory

Definition at line 62 of file BlockUtils.php.

References MediaWiki\Block\BlockUtils\$options, MediaWiki\Block\BlockUtils\$userFactory, and MediaWiki\Config\ServiceOptions\assertRequiredOptions().

Member Function Documentation

◆ parseBlockTarget()

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

From an existing block, get the target and the type of target.

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

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

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

Definition at line 83 of file BlockUtils.php.

References MediaWiki\Block\AbstractBlock\TYPE_AUTO, MediaWiki\Block\AbstractBlock\TYPE_IP, MediaWiki\Block\AbstractBlock\TYPE_RANGE, and MediaWiki\Block\AbstractBlock\TYPE_USER.

Referenced by SpecialBlock\processFormInternal(), and MediaWiki\Block\BlockUtils\validateTarget().

◆ validateIPv4Range()

MediaWiki\Block\BlockUtils::validateIPv4Range ( int  $range)
private

Validate an IPv4 range.

Parameters
int$range
Returns
Status

Definition at line 189 of file BlockUtils.php.

References StatusValue\newGood().

Referenced by MediaWiki\Block\BlockUtils\validateTarget().

◆ validateIPv6Range()

MediaWiki\Block\BlockUtils::validateIPv6Range ( int  $range)
private

Validate an IPv6 range.

Parameters
int$range
Returns
Status

Definition at line 213 of file BlockUtils.php.

References StatusValue\newGood().

Referenced by MediaWiki\Block\BlockUtils\validateTarget().

◆ validateTarget()

Member Data Documentation

◆ $options

ServiceOptions MediaWiki\Block\BlockUtils::$options
private

Definition at line 46 of file BlockUtils.php.

Referenced by MediaWiki\Block\BlockUtils\__construct().

◆ $userFactory

UserFactory MediaWiki\Block\BlockUtils::$userFactory
private

Definition at line 49 of file BlockUtils.php.

Referenced by MediaWiki\Block\BlockUtils\__construct().

◆ CONSTRUCTOR_OPTIONS

const MediaWiki\Block\BlockUtils::CONSTRUCTOR_OPTIONS
Initial value:
= [
'BlockCIDRLimit',
]

Definition at line 54 of file BlockUtils.php.


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