MediaWiki  master
MissingCommentConstraint.php
Go to the documentation of this file.
1 <?php
22 
23 use StatusValue;
24 
33 
35  private $userComment;
36 
40  public function __construct( string $userComment ) {
41  $this->userComment = $userComment;
42  }
43 
44  public function checkConstraint(): string {
45  if ( $this->userComment == '' ) {
46  // TODO this was == in EditPage, can it be === ?
47  return self::CONSTRAINT_FAILED;
48  }
49  return self::CONSTRAINT_PASSED;
50  }
51 
52  public function getLegacyStatus(): StatusValue {
53  $statusValue = StatusValue::newGood();
54  if ( $this->userComment == '' ) {
55  $statusValue->fatal( 'missingcommenttext' );
56  $statusValue->value = self::AS_TEXTBOX_EMPTY;
57  }
58  return $statusValue;
59  }
60 
61 }
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: StatusValue.php:43
MediaWiki\EditPage\IEditObject\AS_TEXTBOX_EMPTY
const AS_TEXTBOX_EMPTY
Status: user tried to create a new section without content.
Definition: IEditObject.php:80
MediaWiki\EditPage\Constraint\MissingCommentConstraint\__construct
__construct(string $userComment)
Definition: MissingCommentConstraint.php:40
MediaWiki\EditPage\Constraint\MissingCommentConstraint\getLegacyStatus
getLegacyStatus()
Get the legacy status for failure (or success)
Definition: MissingCommentConstraint.php:52
MediaWiki\EditPage\Constraint\MissingCommentConstraint
Do not allow the user to post an empty comment (only used for new section)
Definition: MissingCommentConstraint.php:32
MediaWiki\EditPage\Constraint\MissingCommentConstraint\$userComment
string $userComment
Definition: MissingCommentConstraint.php:35
MediaWiki\EditPage\Constraint\MissingCommentConstraint\checkConstraint
checkConstraint()
Definition: MissingCommentConstraint.php:44
StatusValue\newGood
static newGood( $value=null)
Factory function for good results.
Definition: StatusValue.php:82
MediaWiki\EditPage\Constraint
Definition: AccidentalRecreationConstraint.php:21
MediaWiki\EditPage\Constraint\IEditConstraint
Interface for all constraints that can prevent edits.
Definition: IEditConstraint.php:33