MediaWiki master
MissingCommentConstraint.php
Go to the documentation of this file.
1<?php
8
10
19
20 private bool $failed = false;
21
22 public function __construct(
23 private readonly string $section,
24 private readonly string $userComment,
25 ) {
26 }
27
28 public function checkConstraint(): string {
29 if ( $this->section === 'new' && $this->userComment === '' ) {
30 $this->failed = true;
31 return self::CONSTRAINT_FAILED;
32 }
33 return self::CONSTRAINT_PASSED;
34 }
35
36 public function getLegacyStatus(): StatusValue {
37 $statusValue = StatusValue::newGood();
38 if ( $this->failed ) {
39 $statusValue->fatal( 'missingcommenttext' );
40 $statusValue->value = self::AS_TEXTBOX_EMPTY;
41 }
42 return $statusValue;
43 }
44
45}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:68
Do not allow the user to post an empty comment (only used for new section)
__construct(private readonly string $section, private readonly string $userComment,)
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.