MediaWiki master
UserBlockConstraint.php
Go to the documentation of this file.
1<?php
22
26use StatusValue;
27
37
38 private PermissionManager $permissionManager;
39 private LinkTarget $title;
40 private User $user;
41 private string $result;
42
48 public function __construct(
49 PermissionManager $permissionManager,
50 LinkTarget $title,
51 User $user
52 ) {
53 $this->permissionManager = $permissionManager;
54 $this->title = $title;
55 $this->user = $user;
56 }
57
58 public function checkConstraint(): string {
59 // Check isn't simple enough to just repeat when getting the status
60 if ( $this->permissionManager->isBlockedFrom( $this->user, $this->title ) ) {
61 $this->result = self::CONSTRAINT_FAILED;
62 return self::CONSTRAINT_FAILED;
63 }
64
65 $this->result = self::CONSTRAINT_PASSED;
66 return self::CONSTRAINT_PASSED;
67 }
68
69 public function getLegacyStatus(): StatusValue {
70 $statusValue = StatusValue::newGood();
71
72 if ( $this->result === self::CONSTRAINT_FAILED ) {
73 $statusValue->setResult( false, self::AS_BLOCKED_PAGE_FOR_USER );
74 }
75
76 return $statusValue;
77 }
78
79}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
Verify user permissions: Must not be blocked from the page.
getLegacyStatus()
Get the legacy status for failure (or success)
__construct(PermissionManager $permissionManager, LinkTarget $title, User $user)
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
internal since 1.36
Definition User.php:93
Generic operation result class Has warning/error list, boolean status and arbitrary value.
setResult( $ok, $value=null)
Change operation result.
Interface for all constraints that can prevent edits.
Represents the target of a wiki link.