45 private $newContentModel;
58 string $newContentModel
60 $this->performer = $performer;
61 $this->title = $title;
62 $this->newContentModel = $newContentModel;
66 if ( $this->newContentModel === $this->title->getContentModel() ) {
68 $this->result = self::CONSTRAINT_PASSED;
69 return self::CONSTRAINT_PASSED;
72 if ( !$this->performer->isAllowed(
'editcontentmodel' ) ) {
73 $this->result = self::CONSTRAINT_FAILED;
74 return self::CONSTRAINT_FAILED;
78 $titleWithNewContentModel = clone $this->title;
79 $titleWithNewContentModel->setContentModel( $this->newContentModel );
81 $canEditModel = $this->performer->authorizeWrite(
83 $titleWithNewContentModel
88 || !$this->performer->authorizeWrite(
'edit', $titleWithNewContentModel )
90 $this->result = self::CONSTRAINT_FAILED;
91 return self::CONSTRAINT_FAILED;
94 $this->result = self::CONSTRAINT_PASSED;
95 return self::CONSTRAINT_PASSED;
101 if ( $this->result === self::CONSTRAINT_FAILED ) {
102 $statusValue->
setResult(
false, self::AS_NO_CHANGE_CONTENT_MODEL );
if(!defined('MW_SETUP_CALLBACK'))
Verify user permissions if changing content model: Must have editcontentmodel rights Must be able to ...
getLegacyStatus()
Get the legacy status for failure (or success)
__construct(Authority $performer, Title $title, string $newContentModel)
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.