MediaWiki  master
AccidentalRecreationConstraint.php
Go to the documentation of this file.
1 <?php
22 
23 use StatusValue;
24 
33 
36 
39 
44  public function __construct(
46  bool $allowRecreation
47  ) {
48  $this->deletedSinceLastEdit = $deletedSinceLastEdit;
49  $this->allowRecreation = $allowRecreation;
50  }
51 
52  public function checkConstraint(): string {
53  if ( $this->deletedSinceLastEdit && !$this->allowRecreation ) {
54  return self::CONSTRAINT_FAILED;
55  }
56  return self::CONSTRAINT_PASSED;
57  }
58 
59  public function getLegacyStatus(): StatusValue {
60  $statusValue = StatusValue::newGood();
61  if ( $this->deletedSinceLastEdit && !$this->allowRecreation ) {
62  $statusValue->setResult( false, self::AS_ARTICLE_WAS_DELETED );
63  }
64  return $statusValue;
65  }
66 
67 }
StatusValue
Generic operation result class Has warning/error list, boolean status and arbitrary value.
Definition: StatusValue.php:43
MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint\__construct
__construct(bool $deletedSinceLastEdit, bool $allowRecreation)
Definition: AccidentalRecreationConstraint.php:44
MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint\getLegacyStatus
getLegacyStatus()
Get the legacy status for failure (or success)
Definition: AccidentalRecreationConstraint.php:59
MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint\checkConstraint
checkConstraint()
Definition: AccidentalRecreationConstraint.php:52
MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint
Make sure user doesn't accidentally recreate a page deleted after they started editing.
Definition: AccidentalRecreationConstraint.php:32
MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint\$deletedSinceLastEdit
bool $deletedSinceLastEdit
Definition: AccidentalRecreationConstraint.php:35
MediaWiki\EditPage\Constraint\AccidentalRecreationConstraint\$allowRecreation
bool $allowRecreation
Definition: AccidentalRecreationConstraint.php:38
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