Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
PageStoreFactory
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
7 / 7
100.00% covered (success)
100.00%
1 / 1
1
 getPageStore
100.00% covered (success)
100.00%
9 / 9
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace MediaWiki\Page;
4
5use MediaWiki\Config\ServiceOptions;
6use MediaWiki\DAO\WikiAwareEntity;
7use MediaWiki\Title\NamespaceInfo;
8use MediaWiki\Title\TitleParser;
9use Wikimedia\Rdbms\ILBFactory;
10use Wikimedia\Stats\StatsFactory;
11
12/**
13 * @since 1.36
14 */
15class PageStoreFactory {
16
17    /**
18     * @internal For use by service wiring
19     */
20    public const CONSTRUCTOR_OPTIONS = PageStore::CONSTRUCTOR_OPTIONS;
21
22    private ServiceOptions $options;
23    private ILBFactory $dbLoadBalancerFactory;
24    private NamespaceInfo $namespaceInfo;
25    private TitleParser $titleParser;
26    private LinkCache $linkCache;
27    private StatsFactory $stats;
28
29    public function __construct(
30        ServiceOptions $options,
31        ILBFactory $dbLoadBalancerFactory,
32        NamespaceInfo $namespaceInfo,
33        TitleParser $titleParser,
34        LinkCache $linkCache,
35        StatsFactory $stats
36    ) {
37        $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
38
39        $this->options = $options;
40        $this->dbLoadBalancerFactory = $dbLoadBalancerFactory;
41        $this->namespaceInfo = $namespaceInfo;
42        $this->titleParser = $titleParser;
43        $this->linkCache = $linkCache;
44        $this->stats = $stats;
45    }
46
47    /**
48     * @param string|false $wikiId
49     *
50     * @return PageStore
51     */
52    public function getPageStore( $wikiId = WikiAwareEntity::LOCAL ): PageStore {
53        return new PageStore(
54            $this->options,
55            $this->dbLoadBalancerFactory->getMainLB( $wikiId ),
56            $this->namespaceInfo,
57            $this->titleParser,
58            $wikiId !== WikiAwareEntity::LOCAL ? null : $this->linkCache,
59            $this->stats,
60            $wikiId
61        );
62    }
63
64}