MediaWiki master
ChangeTagsConstraint.php
Go to the documentation of this file.
1<?php
6
7namespace MediaWiki\EditPage\Constraint;
8
9use MediaWiki\ChangeTags\ChangeTags;
10use MediaWiki\PageEdit\PageEditStatus;
11use MediaWiki\Permissions\Authority;
12
21
26 public function __construct(
27 private readonly Authority $performer,
28 private readonly array $tags,
29 ) {
30 }
31
32 public function checkConstraint(): PageEditStatus {
33 if ( !$this->tags ) {
34 return PageEditStatus::newGood();
35 }
36
37 // TODO inject a service once canAddTagsAccompanyingChange is moved to a
38 // service as part of T245964
39 $changeTagStatus = ChangeTags::canAddTagsAccompanyingChange(
40 $this->tags,
41 $this->performer,
42 false
43 );
44
45 return PageEditStatus::cast( $changeTagStatus )
46 ->setValue( self::AS_CHANGE_TAG_ERROR );
47 }
48
49}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:72
__construct(private readonly Authority $performer, private readonly array $tags,)
Abstract class for all constraints that can prevent edits.
Status returned by edit constraints and other page editing checks.
This interface represents the authority associated with the current execution context,...
Definition Authority.php:23