MediaWiki master
BlockUtils.php
Go to the documentation of this file.
1<?php
2
8namespace MediaWiki\Block;
9
12
29 private BlockTargetFactory $blockTargetFactory;
30
31 public function __construct( BlockTargetFactory $blockTargetFactory ) {
32 $this->blockTargetFactory = $blockTargetFactory;
33 }
34
53 public function parseBlockTarget( $target ): array {
54 $targetObj = $this->blockTargetFactory->newFromLegacyUnion( $target );
55 if ( $targetObj ) {
56 return $targetObj->getLegacyTuple();
57 } else {
58 return [ null, null ];
59 }
60 }
61
70 public function parseBlockTargetRow( $row ) {
71 $target = $this->blockTargetFactory->newFromRowRedacted( $row );
72 if ( $target ) {
73 return $target->getLegacyTuple();
74 } else {
75 return [ null, null ];
76 }
77 }
78
86 public function validateTarget( $value ): Status {
87 $target = $this->blockTargetFactory->newFromLegacyUnion( $value );
88 if ( $target ) {
89 return Status::wrap( $target->validateForCreation() );
90 } else {
91 return Status::newFatal( 'badipaddress' );
92 }
93 }
94
95}
Factory for BlockTarget objects.
Backend class for blocking utils.
parseBlockTarget( $target)
From string specification or UserIdentity, get the block target and the type of target.
__construct(BlockTargetFactory $blockTargetFactory)
parseBlockTargetRow( $row)
From a row which must contain bt_auto, bt_user, bt_address and bl_id, and optionally bt_user_text,...
validateTarget( $value)
Validate block target.
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition Status.php:44
Interface for objects representing user identity.