MediaWiki REL1_35
ContentModelChange Class Reference

Helper class to change the content model of pages. More...

Collaboration diagram for ContentModelChange:

Public Member Functions

 __construct (IContentHandlerFactory $contentHandlerFactory, HookContainer $hookContainer, PermissionManager $permManager, RevisionLookup $revLookup, User $user, WikiPage $page, string $newModel)
 
 checkPermissions ()
 Check user can edit and editcontentmodel before and after.
 
 doContentModelChange (IContextSource $context, $comment, $bot)
 Handle change and logging after validatio.
 
 setMessagePrefix ( $msgPrefix)
 Set the message prefix.
 
 setTags ( $tags)
 Specify the tags the user wants to add, and check permissions.
 

Private Member Functions

 createNewContent ()
 Create the new content.
 

Private Attributes

IContentHandlerFactory $contentHandlerFactory
 
HookRunner $hookRunner
 
int false $latestRevId
 latest revision id, or false if creating
 
string $logAction
 'new' or 'change'
 
string $msgPrefix
 'apierror-' or empty string, for status messages
 
Content $newContent
 
string $newModel
 
WikiPage $page
 
PermissionManager $permManager
 
RevisionLookup $revLookup
 
string[] $tags
 tags to add
 
User $user
 user making the change
 

Detailed Description

Helper class to change the content model of pages.

For creating new pages via the action API, use the edit api and specify the desired content model and format.

Since
1.35
Author
DannyS712

Definition at line 19 of file ContentModelChange.php.

Constructor & Destructor Documentation

◆ __construct()

ContentModelChange::__construct ( IContentHandlerFactory  $contentHandlerFactory,
HookContainer  $hookContainer,
PermissionManager  $permManager,
RevisionLookup  $revLookup,
User  $user,
WikiPage  $page,
string  $newModel 
)
Parameters
IContentHandlerFactory$contentHandlerFactory
HookContainer$hookContainer
PermissionManager$permManager
RevisionLookup$revLookup
User$user
WikiPage$page
string$newModel

Definition at line 66 of file ContentModelChange.php.

Member Function Documentation

◆ checkPermissions()

ContentModelChange::checkPermissions ( )

Check user can edit and editcontentmodel before and after.

Returns
array from wfMergeErrorArrays

Definition at line 110 of file ContentModelChange.php.

References wfMergeErrorArrays().

◆ createNewContent()

ContentModelChange::createNewContent ( )
private

Create the new content.

Returns
Status

Definition at line 160 of file ContentModelChange.php.

References $title, MediaWiki\Content\IContentHandlerFactory\getContentHandler(), and Message\plaintextParam().

Referenced by doContentModelChange().

◆ doContentModelChange()

ContentModelChange::doContentModelChange ( IContextSource  $context,
  $comment,
  $bot 
)

Handle change and logging after validatio.

Can still be intercepted by hooks

Parameters
IContextSource$context
string$comment
bool$botMark as a bot edit if the user can
Returns
Status
Exceptions
ThrottledError

Definition at line 231 of file ContentModelChange.php.

References $title, createNewContent(), WikiPage\doEditContent(), EDIT_FORCE_BOT, EDIT_INTERNAL, EDIT_NEW, EDIT_UPDATE, WikiPage\getTitle(), LogFormatter\newFromEntry(), User\pingLimiter(), and wfMessage().

◆ setMessagePrefix()

ContentModelChange::setMessagePrefix (   $msgPrefix)

Set the message prefix.

Parameters
string$msgPrefix

Definition at line 101 of file ContentModelChange.php.

◆ setTags()

ContentModelChange::setTags (   $tags)

Specify the tags the user wants to add, and check permissions.

Parameters
string[]$tags
Returns
Status

Definition at line 145 of file ContentModelChange.php.

References ChangeTags\canAddTagsAccompanyingChange().

Member Data Documentation

◆ $contentHandlerFactory

IContentHandlerFactory ContentModelChange::$contentHandlerFactory
private

Definition at line 22 of file ContentModelChange.php.

◆ $hookRunner

HookRunner ContentModelChange::$hookRunner
private

Definition at line 25 of file ContentModelChange.php.

◆ $latestRevId

int false ContentModelChange::$latestRevId
private

latest revision id, or false if creating

Definition at line 49 of file ContentModelChange.php.

◆ $logAction

string ContentModelChange::$logAction
private

'new' or 'change'

Definition at line 52 of file ContentModelChange.php.

◆ $msgPrefix

string ContentModelChange::$msgPrefix
private

'apierror-' or empty string, for status messages

Definition at line 55 of file ContentModelChange.php.

◆ $newContent

Content ContentModelChange::$newContent
private

Definition at line 46 of file ContentModelChange.php.

◆ $newModel

string ContentModelChange::$newModel
private

Definition at line 40 of file ContentModelChange.php.

◆ $page

WikiPage ContentModelChange::$page
private

Definition at line 37 of file ContentModelChange.php.

◆ $permManager

PermissionManager ContentModelChange::$permManager
private

Definition at line 28 of file ContentModelChange.php.

◆ $revLookup

RevisionLookup ContentModelChange::$revLookup
private

Definition at line 31 of file ContentModelChange.php.

◆ $tags

string [] ContentModelChange::$tags
private

tags to add

Definition at line 43 of file ContentModelChange.php.

◆ $user

User ContentModelChange::$user
private

user making the change

Definition at line 34 of file ContentModelChange.php.


The documentation for this class was generated from the following file: