MediaWiki master
DefaultTextConstraint.php
Go to the documentation of this file.
1<?php
8
12
23
30 public function __construct(
31 private readonly Title $title,
32 private readonly bool $allowBlank,
33 private readonly string $userProvidedText,
34 private readonly string $submitButtonLabel,
35 ) {
36 }
37
38 public function checkConstraint(): EditPageStatus {
39 $defaultMessageText = $this->title->getDefaultMessageText();
40 if ( $this->title->getNamespace() === NS_MEDIAWIKI && $defaultMessageText !== false ) {
41 $defaultText = $defaultMessageText;
42 } else {
43 $defaultText = '';
44 }
45
46 if ( !$this->allowBlank && $this->userProvidedText === $defaultText ) {
47 return EditPageStatus::newGood( self::AS_BLANK_ARTICLE )
48 ->setOK( false )
49 ->warning( 'blankarticle', MessageValue::new( $this->submitButtonLabel ) );
50 }
52 }
53
54}
const NS_MEDIAWIKI
Definition Defines.php:59
Don't save a new page if it's blank or if it's a MediaWiki: message with content equivalent to defaul...
__construct(private readonly Title $title, private readonly bool $allowBlank, private readonly string $userProvidedText, private readonly string $submitButtonLabel,)
Abstract class for all constraints that can prevent edits.
Status returned by edit constraints and other page editing checks.
Represents a title within MediaWiki.
Definition Title.php:69
setOK( $ok)
Change operation status.
static newGood( $value=null)
Factory function for good results.
Value object representing a message for i18n.