MediaWiki  master
PageCommandFactory.php
Go to the documentation of this file.
1 <?php
2 
23 namespace MediaWiki\Page;
24 
32 use MergeHistory;
33 use MovePage;
34 use NamespaceInfo;
35 use RepoGroup;
36 use Title;
37 use User;
40 use WikiPage;
41 
49  private $options;
50 
52  private $loadBalancer;
53 
55  private $namespaceInfo;
56 
59 
62 
64  private $repoGroup;
65 
68 
70  private $revisionStore;
71 
73  private $spamChecker;
74 
76  private $hookContainer;
77 
81  public const CONSTRUCTOR_OPTIONS = [
82  'CategoryCollation'
83  ];
84 
85  public function __construct(
86  ServiceOptions $options,
87  ILoadBalancer $loadBalancer,
90  PermissionManager $permissionManager,
92  IContentHandlerFactory $contentHandlerFactory,
93  RevisionStore $revisionStore,
94  SpamChecker $spamChecker,
95  HookContainer $hookContainer
96  ) {
97  $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
98 
99  $this->options = $options;
100  $this->loadBalancer = $loadBalancer;
101  $this->namespaceInfo = $namespaceInfo;
102  $this->watchedItemStore = $watchedItemStore;
103  $this->permissionManager = $permissionManager;
104  $this->repoGroup = $repoGroup;
105  $this->contentHandlerFactory = $contentHandlerFactory;
106  $this->revisionStore = $revisionStore;
107  $this->spamChecker = $spamChecker;
108  $this->hookContainer = $hookContainer;
109  }
110 
117  public function newContentModelChange(
118  User $user,
119  WikiPage $wikipage,
120  string $newContentModel
121  ) : ContentModelChange {
122  return new ContentModelChange(
123  $this->contentHandlerFactory,
124  $this->hookContainer,
125  $this->permissionManager,
126  $this->revisionStore,
127  $user,
128  $wikipage,
129  $newContentModel
130  );
131  }
132 
139  public function newMergeHistory(
140  Title $source,
141  Title $destination,
142  string $timestamp = null
143  ) : MergeHistory {
144  if ( $timestamp === null ) {
145  // For compatibility with MergeHistory constructor until it can be changed
146  $timestamp = false;
147  }
148  return new MergeHistory(
149  $source,
150  $destination,
151  $timestamp,
152  $this->loadBalancer,
153  $this->permissionManager,
154  $this->contentHandlerFactory,
155  $this->revisionStore,
156  $this->watchedItemStore,
157  $this->spamChecker,
158  $this->hookContainer
159  );
160  }
161 
167  public function newMovePage( Title $from, Title $to ) : MovePage {
168  return new MovePage(
169  $from,
170  $to,
171  $this->options,
172  $this->loadBalancer,
173  $this->namespaceInfo,
174  $this->watchedItemStore,
175  $this->permissionManager,
176  $this->repoGroup,
177  $this->contentHandlerFactory,
178  $this->revisionStore,
179  $this->spamChecker,
180  $this->hookContainer
181  );
182  }
183 }
Page\PageCommandFactory\$hookContainer
HookContainer $hookContainer
Definition: PageCommandFactory.php:76
Page\PageCommandFactory\$options
ServiceOptions $options
Definition: PageCommandFactory.php:49
Revision\RevisionStore
Service for looking up page revisions.
Definition: RevisionStore.php:81
Page\PageCommandFactory\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: PageCommandFactory.php:55
Page\PageCommandFactory\newContentModelChange
newContentModelChange(User $user, WikiPage $wikipage, string $newContentModel)
Definition: PageCommandFactory.php:117
WikiPage
Class representing a MediaWiki article and history.
Definition: WikiPage.php:53
Page\PageCommandFactory\$spamChecker
SpamChecker $spamChecker
Definition: PageCommandFactory.php:73
Page\PageCommandFactory\__construct
__construct(ServiceOptions $options, ILoadBalancer $loadBalancer, NamespaceInfo $namespaceInfo, WatchedItemStoreInterface $watchedItemStore, PermissionManager $permissionManager, RepoGroup $repoGroup, IContentHandlerFactory $contentHandlerFactory, RevisionStore $revisionStore, SpamChecker $spamChecker, HookContainer $hookContainer)
Definition: PageCommandFactory.php:85
Page\PageCommandFactory\$loadBalancer
ILoadBalancer $loadBalancer
Definition: PageCommandFactory.php:52
Page\PageCommandFactory\CONSTRUCTOR_OPTIONS
const CONSTRUCTOR_OPTIONS
Definition: PageCommandFactory.php:81
Page\MergeHistoryFactory
Definition: MergeHistoryFactory.php:31
Page\PageCommandFactory\$watchedItemStore
WatchedItemStoreInterface $watchedItemStore
Definition: PageCommandFactory.php:58
Page\PageCommandFactory\newMovePage
newMovePage(Title $from, Title $to)
Definition: PageCommandFactory.php:167
MediaWiki\Config\ServiceOptions
A class for passing options to services.
Definition: ServiceOptions.php:25
MovePage
Handles the backend logic of moving a page from one title to another.
Definition: MovePage.php:42
Page\PageCommandFactory\$revisionStore
RevisionStore $revisionStore
Definition: PageCommandFactory.php:70
MediaWiki\Permissions\PermissionManager
A service class for checking permissions To obtain an instance, use MediaWikiServices::getInstance()-...
Definition: PermissionManager.php:49
Page\PageCommandFactory\$permissionManager
PermissionManager $permissionManager
Definition: PageCommandFactory.php:61
MediaWiki\Content\IContentHandlerFactory
Definition: IContentHandlerFactory.php:10
MediaWiki\EditPage\SpamChecker
Service to check if text (either content or a summary) qualifies as spam.
Definition: SpamChecker.php:14
Page\PageCommandFactory\$contentHandlerFactory
IContentHandlerFactory $contentHandlerFactory
Definition: PageCommandFactory.php:67
MergeHistory
Handles the backend logic of merging the histories of two pages.
Definition: MergeHistory.php:43
Page\MovePageFactory
Definition: MovePageFactory.php:30
Page\PageCommandFactory
Common factory to construct page handling classes.
Definition: PageCommandFactory.php:47
Title
Represents a title within MediaWiki.
Definition: Title.php:41
Page\ContentModelChangeFactory
Definition: ContentModelChangeFactory.php:32
RepoGroup
Prioritized list of file repositories.
Definition: RepoGroup.php:31
MediaWiki\Page
Definition: ContentModelChangeFactory.php:23
$source
$source
Definition: mwdoc-filter.php:34
MediaWiki\HookContainer\HookContainer
HookContainer class.
Definition: HookContainer.php:44
Page\PageCommandFactory\newMergeHistory
newMergeHistory(Title $source, Title $destination, string $timestamp=null)
Definition: PageCommandFactory.php:139
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
WatchedItemStoreInterface
Definition: WatchedItemStoreInterface.php:30
User
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
Definition: User.php:55
Page\PageCommandFactory\$repoGroup
RepoGroup $repoGroup
Definition: PageCommandFactory.php:64
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
ContentModelChange
Helper class to change the content model of pages.
Definition: ContentModelChange.php:19