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
41 public function __construct( string $section, string $userComment ) {
42 $this->section = $section;
43 $this->userComment = $userComment;
44 }
45
46 public function checkConstraint(): string {
47 if ( $this->section === 'new' && $this->userComment === '' ) {
48 return self::CONSTRAINT_FAILED;
49 }
50 return self::CONSTRAINT_PASSED;
51 }
52
53 public function getLegacyStatus(): StatusValue {
54 $statusValue = StatusValue::newGood();
55 if ( $this->section === 'new' && $this->userComment === '' ) {
56 $statusValue->fatal( 'missingcommenttext' );
57 $statusValue->value = self::AS_TEXTBOX_EMPTY;
58 }
59 return $statusValue;
60 }
61
62}
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.