MediaWiki
master
Toggle main menu visibility
NewSectionMissingSubjectConstraint.php
Go to the documentation of this file.
1
<?php
6
7
namespace
MediaWiki\EditPage\Constraint;
8
9
use MediaWiki\PageEdit\PageEditAttemptState;
10
use MediaWiki\PageEdit\PageEditStatus;
11
19
class
NewSectionMissingSubjectConstraint
extends
EditConstraint
{
20
21
public
function
__construct
(
22
private
readonly
string
$section,
23
private
readonly
string
$subject,
24
private
readonly
bool
$forceEditSummary,
25
private
readonly
PageEditAttemptState
$editAttemptState,
26
) {
27
}
28
29
public
function
checkConstraint
():
PageEditStatus
{
30
if
( $this->section ===
'new'
&&
31
$this->forceEditSummary &&
32
!$this->editAttemptState->shouldAllowBlankSummary() &&
33
trim( $this->subject ) ===
''
34
) {
35
$this->editAttemptState->setAllowBlankSummary(
true
);
36
return
PageEditStatus::newGood( self::AS_SUMMARY_NEEDED )
37
->setOK(
false
)
38
->setCanResubmit(
true
)
39
->warning(
'edit-constraint-newsectionmissingsubject-warning'
);
40
}
41
42
return
PageEditStatus::newGood();
43
}
44
45
}
if
if(!defined('MW_SETUP_CALLBACK'))
Definition
WebStart.php:72
MediaWiki\EditPage\Constraint\EditConstraint
Abstract class for all constraints that can prevent edits.
Definition
EditConstraint.php:18
MediaWiki\EditPage\Constraint\NewSectionMissingSubjectConstraint
For a new section, do not allow the user to post with an empty subject (section title) unless they ch...
Definition
NewSectionMissingSubjectConstraint.php:19
MediaWiki\EditPage\Constraint\NewSectionMissingSubjectConstraint\__construct
__construct(private readonly string $section, private readonly string $subject, private readonly bool $forceEditSummary, private readonly PageEditAttemptState $editAttemptState,)
Definition
NewSectionMissingSubjectConstraint.php:21
MediaWiki\EditPage\Constraint\NewSectionMissingSubjectConstraint\checkConstraint
checkConstraint()
Definition
NewSectionMissingSubjectConstraint.php:29
MediaWiki\PageEdit\PageEditAttemptState
Data returned by an edit attempt that can be passed to the next one to allow bypassing certain warnin...
Definition
PageEditAttemptState.php:14
MediaWiki\PageEdit\PageEditStatus
Status returned by edit constraints and other page editing checks.
Definition
PageEditStatus.php:19
includes
EditPage
Constraint
NewSectionMissingSubjectConstraint.php
Generated on
for MediaWiki by
1.18.0