MediaWiki
master
MissingCommentConstraint.php
Go to the documentation of this file.
1
<?php
21
namespace
MediaWiki\EditPage\Constraint
;
22
23
use
StatusValue
;
24
32
class
MissingCommentConstraint
implements
IEditConstraint
{
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
}
if
if(!defined('MW_SETUP_CALLBACK'))
Definition
WebStart.php:81
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\checkConstraint
checkConstraint()
Definition
MissingCommentConstraint.php:44
MediaWiki\EditPage\Constraint\MissingCommentConstraint\getLegacyStatus
getLegacyStatus()
Get the legacy status for failure (or success)
Definition
MissingCommentConstraint.php:52
MediaWiki\EditPage\Constraint\MissingCommentConstraint\__construct
__construct(string $userComment)
Definition
MissingCommentConstraint.php:40
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition
StatusValue.php:49
StatusValue\fatal
fatal( $message,... $parameters)
Add an error and set OK to false, indicating that the operation as a whole was fatal.
Definition
StatusValue.php:288
MediaWiki\EditPage\Constraint\IEditConstraint
Interface for all constraints that can prevent edits.
Definition
IEditConstraint.php:33
MediaWiki\EditPage\Constraint
Definition
AccidentalRecreationConstraint.php:21
includes
editpage
Constraint
MissingCommentConstraint.php
Generated on Wed Apr 24 2024 22:22:28 for MediaWiki by
1.10.0