MediaWiki  master
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, RevisionLookup $revLookup, UserFactory $userFactory, Authority $performer, WikiPage $page, string $newModel)
 
 authorizeChange ()
 Authorize the move by $performer. More...
 
 checkPermissions ()
 Check user can edit and editcontentmodel before and after. More...
 
 doContentModelChange (IContextSource $context, $comment, $bot)
 Handle change and logging after validation. More...
 
 probablyCanChange ()
 Check whether $performer can execute the move. More...
 
 setMessagePrefix ( $msgPrefix)
 
 setTags ( $tags)
 Specify the tags the user wants to add, and check permissions. More...
 

Private Member Functions

 authorizeInternal (callable $authorizer)
 
 createNewContent ()
 

Private Attributes

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

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 22 of file ContentModelChange.php.

Constructor & Destructor Documentation

◆ __construct()

ContentModelChange::__construct ( IContentHandlerFactory  $contentHandlerFactory,
HookContainer  $hookContainer,
RevisionLookup  $revLookup,
UserFactory  $userFactory,
Authority  $performer,
WikiPage  $page,
string  $newModel 
)
Parameters
IContentHandlerFactory$contentHandlerFactory
HookContainer$hookContainer
RevisionLookup$revLookup
UserFactory$userFactory
Authority$performer
WikiPage$page
string$newModel

Definition at line 69 of file ContentModelChange.php.

References $contentHandlerFactory, $newModel, $page, $performer, $revLookup, and $userFactory.

Member Function Documentation

◆ authorizeChange()

ContentModelChange::authorizeChange ( )

Authorize the move by $performer.

Note
this method should be used right before the actual move is performed. To check whether a current performer has the potential to move the page, use self::probablyCanChange instead.
Returns
PermissionStatus

Definition at line 149 of file ContentModelChange.php.

References authorizeInternal().

◆ authorizeInternal()

ContentModelChange::authorizeInternal ( callable  $authorizer)
private
Parameters
callable$authorizer( string $action, PageIdentity $target, PermissionStatus $status )
Returns
PermissionStatus

Definition at line 110 of file ContentModelChange.php.

Referenced by authorizeChange(), checkPermissions(), and probablyCanChange().

◆ checkPermissions()

ContentModelChange::checkPermissions ( )

Check user can edit and editcontentmodel before and after.

Deprecated:
since 1.36. Use ::probablyCanChange or ::authorizeChange instead.
Returns
array from wfMergeErrorArrays

Definition at line 163 of file ContentModelChange.php.

References authorizeInternal(), MediaWiki\Permissions\PermissionStatus\toLegacyErrorArray(), and wfDeprecated().

◆ createNewContent()

◆ doContentModelChange()

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

Handle change and logging after validation.

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 262 of file ContentModelChange.php.

References $newContent, $page, $title, createNewContent(), WikiPage\doUserEditContent(), EDIT_FORCE_BOT, EDIT_INTERNAL, EDIT_NEW, EDIT_UPDATE, WikiPage\getTitle(), RequestContext\newExtraneousContext(), LogFormatter\newFromEntry(), StatusValue\newGood(), and wfMessage().

◆ probablyCanChange()

ContentModelChange::probablyCanChange ( )

Check whether $performer can execute the move.

Note
this method does not guarantee full permissions check, so it should only be used to to decide whether to show a move form. To authorize the move action use self::authorizeChange instead.
Returns
PermissionStatus

Definition at line 132 of file ContentModelChange.php.

References authorizeInternal().

◆ setMessagePrefix()

ContentModelChange::setMessagePrefix (   $msgPrefix)
Parameters
string$msgPrefix

Definition at line 102 of file ContentModelChange.php.

References $msgPrefix.

◆ setTags()

ContentModelChange::setTags (   $tags)

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

Parameters
string[]$tags
Returns
Status

Definition at line 178 of file ContentModelChange.php.

References $tags, ChangeTags\canAddTagsAccompanyingChange(), and StatusValue\newGood().

Member Data Documentation

◆ $contentHandlerFactory

IContentHandlerFactory ContentModelChange::$contentHandlerFactory
private

Definition at line 25 of file ContentModelChange.php.

Referenced by __construct(), and createNewContent().

◆ $hookRunner

HookRunner ContentModelChange::$hookRunner
private

Definition at line 28 of file ContentModelChange.php.

◆ $latestRevId

int false ContentModelChange::$latestRevId
private

latest revision id, or false if creating

Definition at line 52 of file ContentModelChange.php.

◆ $logAction

string ContentModelChange::$logAction
private

'new' or 'change'

Definition at line 55 of file ContentModelChange.php.

◆ $msgPrefix

string ContentModelChange::$msgPrefix
private

'apierror-' or empty string, for status messages

Definition at line 58 of file ContentModelChange.php.

Referenced by setMessagePrefix().

◆ $newContent

Content ContentModelChange::$newContent
private

Definition at line 49 of file ContentModelChange.php.

Referenced by createNewContent(), and doContentModelChange().

◆ $newModel

string ContentModelChange::$newModel
private

Definition at line 43 of file ContentModelChange.php.

Referenced by __construct(), and createNewContent().

◆ $page

WikiPage ContentModelChange::$page
private

Definition at line 40 of file ContentModelChange.php.

Referenced by __construct(), and doContentModelChange().

◆ $performer

Authority ContentModelChange::$performer
private

making the change

Definition at line 37 of file ContentModelChange.php.

Referenced by __construct().

◆ $revLookup

RevisionLookup ContentModelChange::$revLookup
private

Definition at line 31 of file ContentModelChange.php.

Referenced by __construct().

◆ $tags

string [] ContentModelChange::$tags
private

tags to add

Definition at line 46 of file ContentModelChange.php.

Referenced by setTags().

◆ $userFactory

UserFactory ContentModelChange::$userFactory
private

Definition at line 34 of file ContentModelChange.php.

Referenced by __construct().


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