MediaWiki REL1_37
ChangeTagsConstraint.php
Go to the documentation of this file.
1<?php
22
23use ChangeTags;
25use StatusValue;
26
35
37 private $performer;
38
40 private $tags;
41
43 private $result;
44
49 public function __construct(
51 array $tags
52 ) {
53 $this->performer = $performer;
54 $this->tags = $tags;
55 }
56
57 public function checkConstraint(): string {
58 if ( !$this->tags ) {
59 $this->result = self::CONSTRAINT_PASSED;
60 return self::CONSTRAINT_PASSED;
61 }
62
63 // TODO inject a service once canAddTagsAccompanyingChange is moved to a
64 // service as part of T245964
66 $this->tags,
67 $this->performer
68 );
69
70 if ( $changeTagStatus->isOK() ) {
71 $this->result = self::CONSTRAINT_PASSED;
72 return self::CONSTRAINT_PASSED;
73 }
74
75 $this->result = $changeTagStatus; // The same status object is returned
76 return self::CONSTRAINT_FAILED;
77 }
78
79 public function getLegacyStatus(): StatusValue {
80 if ( $this->result === self::CONSTRAINT_PASSED ) {
81 $statusValue = StatusValue::newGood();
82 } else {
83 $statusValue = $this->result;
84 $statusValue->value = self::AS_CHANGE_TAG_ERROR;
85 }
86 return $statusValue;
87 }
88
89}
if(ini_get('mbstring.func_overload')) if(!defined('MW_ENTRY_POINT'))
Pre-config setup: Before loading LocalSettings.php.
Definition Setup.php:88
static canAddTagsAccompanyingChange(array $tags, Authority $performer=null)
Is it OK to allow the user to apply all the specified tags at the same time as they edit/make the cha...
getLegacyStatus()
Get the legacy status for failure (or success)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Interface for all constraints that can prevent edits.
This interface represents the authority associated the current execution context, such as a web reque...
Definition Authority.php:37