Introduce MovePageFactory
[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 Title;
29 use WatchedItemStore;
30 use Wikimedia\Rdbms\LoadBalancer;
31
32 /**
33 * @since 1.34
34 */
35 class MovePageFactory {
36 /** @var ServiceOptions */
37 private $options;
38
39 /** @var LoadBalancer */
40 private $loadBalancer;
41
42 /** @var NamespaceInfo */
43 private $nsInfo;
44
45 /** @var WatchedItemStore */
46 private $watchedItems;
47
48 /** @var PermissionManager */
49 private $permMgr;
50
51 /**
52 * @todo Make this a const when we drop HHVM support (T192166)
53 * @var array
54 */
55 public static $constructorOptions = [
56 'CategoryCollation',
57 'ContentHandlerUseDB',
58 ];
59
60 public function __construct(
61 ServiceOptions $options,
62 LoadBalancer $loadBalancer,
63 NamespaceInfo $nsInfo,
64 WatchedItemStore $watchedItems,
65 PermissionManager $permMgr
66 ) {
67 $options->assertRequiredOptions( self::$constructorOptions );
68
69 $this->options = $options;
70 $this->loadBalancer = $loadBalancer;
71 $this->nsInfo = $nsInfo;
72 $this->watchedItems = $watchedItems;
73 $this->permMgr = $permMgr;
74 }
75
76 /**
77 * @param Title $from
78 * @param Title $to
79 * @return MovePage
80 */
81 public function newMovePage( Title $from, Title $to ) : MovePage {
82 return new MovePage( $from, $to, $this->options, $this->loadBalancer, $this->nsInfo,
83 $this->watchedItems, $this->permMgr );
84 }
85 }