performer = $performer; $this->title = $title; $this->newContentModel = $newContentModel; } public function checkConstraint(): string { if ( $this->newContentModel === $this->title->getContentModel() ) { // No change $this->result = self::CONSTRAINT_PASSED; return self::CONSTRAINT_PASSED; } if ( !$this->performer->isAllowed( 'editcontentmodel' ) ) { $this->result = self::CONSTRAINT_FAILED; return self::CONSTRAINT_FAILED; } // Make sure the user can edit the page under the new content model too $titleWithNewContentModel = clone $this->title; $titleWithNewContentModel->setContentModel( $this->newContentModel ); $canEditModel = $this->performer->authorizeWrite( 'editcontentmodel', $titleWithNewContentModel ); if ( !$canEditModel || !$this->performer->authorizeWrite( 'edit', $titleWithNewContentModel ) ) { $this->result = self::CONSTRAINT_FAILED; return self::CONSTRAINT_FAILED; } $this->result = self::CONSTRAINT_PASSED; return self::CONSTRAINT_PASSED; } public function getLegacyStatus(): StatusValue { $statusValue = StatusValue::newGood(); if ( $this->result === self::CONSTRAINT_FAILED ) { $statusValue->setResult( false, self::AS_NO_CHANGE_CONTENT_MODEL ); } return $statusValue; } }