Merge "Make DBAccessBase use DBConnRef, rename $wiki, and hide getLoadBalancer()"
[lhc/web/wiklou.git] / includes / page / MovePageFactory.php
1 <?php
2
3 /**
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 *
19 * @file
20 */
21
22 namespace MediaWiki\Page;
23
24 use MediaWiki\Config\ServiceOptions;
25 use MediaWiki\Permissions\PermissionManager;
26 use MovePage;
27 use NamespaceInfo;
28 use RepoGroup;
29 use Title;
30 use WatchedItemStore;
31 use WatchedItemStoreInterface;
32 use Wikimedia\Rdbms\ILoadBalancer;
33
34 /**
35 * @since 1.34
36 */
37 class MovePageFactory {
38 /** @var ServiceOptions */
39 private $options;
40
41 /** @var ILoadBalancer */
42 private $loadBalancer;
43
44 /** @var NamespaceInfo */
45 private $nsInfo;
46
47 /** @var WatchedItemStore */
48 private $watchedItems;
49
50 /** @var PermissionManager */
51 private $permMgr;
52
53 /** @var RepoGroup */
54 private $repoGroup;
55
56 /**
57 * @todo Make this a const when we drop HHVM support (T192166)
58 * @var array
59 */
60 public static $constructorOptions = [
61 'CategoryCollation',
62 'ContentHandlerUseDB',
63 ];
64
65 public function __construct(
66 ServiceOptions $options,
67 ILoadBalancer $loadBalancer,
68 NamespaceInfo $nsInfo,
69 WatchedItemStoreInterface $watchedItems,
70 PermissionManager $permMgr,
71 RepoGroup $repoGroup
72 ) {
73 $options->assertRequiredOptions( self::$constructorOptions );
74
75 $this->options = $options;
76 $this->loadBalancer = $loadBalancer;
77 $this->nsInfo = $nsInfo;
78 $this->watchedItems = $watchedItems;
79 $this->permMgr = $permMgr;
80 $this->repoGroup = $repoGroup;
81 }
82
83 /**
84 * @param Title $from
85 * @param Title $to
86 * @return MovePage
87 */
88 public function newMovePage( Title $from, Title $to ) : MovePage {
89 return new MovePage( $from, $to, $this->options, $this->loadBalancer, $this->nsInfo,
90 $this->watchedItems, $this->permMgr, $this->repoGroup );
91 }
92 }