MediaWiki master
MissingCommentConstraint.php
Go to the documentation of this file.
1<?php
22
23use StatusValue;
24
33
34 private string $section;
35 private string $userComment;
36
37 public function __construct( string $section, string $userComment ) {
38 $this->section = $section;
39 $this->userComment = $userComment;
40 }
41
42 public function checkConstraint(): string {
43 if ( $this->section === 'new' && $this->userComment === '' ) {
44 return self::CONSTRAINT_FAILED;
45 }
46 return self::CONSTRAINT_PASSED;
47 }
48
49 public function getLegacyStatus(): StatusValue {
50 $statusValue = StatusValue::newGood();
51 if ( $this->section === 'new' && $this->userComment === '' ) {
52 $statusValue->fatal( 'missingcommenttext' );
53 $statusValue->value = self::AS_TEXTBOX_EMPTY;
54 }
55 return $statusValue;
56 }
57
58}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
Do not allow the user to post an empty comment (only used for new section)
getLegacyStatus()
Get the legacy status for failure (or success)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Interface for all constraints that can prevent edits.