MediaWiki master
BlockUtils.php
Go to the documentation of this file.
1<?php
2
22namespace MediaWiki\Block;
23
26
43 private BlockTargetFactory $blockTargetFactory;
44
45 public function __construct( BlockTargetFactory $blockTargetFactory ) {
46 $this->blockTargetFactory = $blockTargetFactory;
47 }
48
67 public function parseBlockTarget( $target ): array {
68 $targetObj = $this->blockTargetFactory->newFromLegacyUnion( $target );
69 if ( $targetObj ) {
70 return $targetObj->getLegacyTuple();
71 } else {
72 return [ null, null ];
73 }
74 }
75
84 public function parseBlockTargetRow( $row ) {
85 $target = $this->blockTargetFactory->newFromRowRedacted( $row );
86 if ( $target ) {
87 return $target->getLegacyTuple();
88 } else {
89 return [ null, null ];
90 }
91 }
92
100 public function validateTarget( $value ): Status {
101 $target = $this->blockTargetFactory->newFromLegacyUnion( $value );
102 if ( $target ) {
103 return Status::wrap( $target->validateForCreation() );
104 } else {
105 return Status::newFatal( 'badipaddress' );
106 }
107 }
108
109}
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:54
Interface for objects representing user identity.