MediaWiki master
AccidentalRecreationConstraint.php
Go to the documentation of this file.
1<?php
22
23use StatusValue;
24
33
34 private bool $deletedSinceLastEdit;
35 private bool $allowRecreation;
36
37 public function __construct(
38 bool $deletedSinceLastEdit,
39 bool $allowRecreation
40 ) {
41 $this->deletedSinceLastEdit = $deletedSinceLastEdit;
42 $this->allowRecreation = $allowRecreation;
43 }
44
45 public function checkConstraint(): string {
46 if ( $this->deletedSinceLastEdit && !$this->allowRecreation ) {
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->deletedSinceLastEdit && !$this->allowRecreation ) {
55 $statusValue->setResult( false, self::AS_ARTICLE_WAS_DELETED );
56 }
57 return $statusValue;
58 }
59
60}
if(!defined('MW_SETUP_CALLBACK'))
Definition WebStart.php:81
Make sure user doesn't accidentally recreate a page deleted after they started editing.
__construct(bool $deletedSinceLastEdit, bool $allowRecreation)
Generic operation result class Has warning/error list, boolean status and arbitrary value.
setResult( $ok, $value=null)
Change operation result.
Interface for all constraints that can prevent edits.