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\Cache\LinkCache;
6use MediaWiki\Config\ServiceOptions;
7use MediaWiki\DAO\WikiAwareEntity;
8use MediaWiki\Title\NamespaceInfo;
9use MediaWiki\Title\TitleParser;
10use Wikimedia\Rdbms\ILBFactory;
11use Wikimedia\Stats\StatsFactory;
12
13/**
14 * @since 1.36
15 */
16class PageStoreFactory {
17
18    /**
19     * @internal For use by service wiring
20     */
21    public const CONSTRUCTOR_OPTIONS = PageStore::CONSTRUCTOR_OPTIONS;
22
23    /** @var ServiceOptions */
24    private $options;
25
26    /** @var ILBFactory */
27    private $dbLoadBalancerFactory;
28
29    /** @var NamespaceInfo */
30    private $namespaceInfo;
31
32    /** @var TitleParser */
33    private $titleParser;
34
35    /** @var LinkCache */
36    private $linkCache;
37
38    /** @var StatsFactory */
39    private $stats;
40
41    /**
42     * @param ServiceOptions $options
43     * @param ILBFactory $dbLoadBalancerFactory
44     * @param NamespaceInfo $namespaceInfo
45     * @param TitleParser $titleParser
46     * @param LinkCache $linkCache
47     * @param StatsFactory $stats
48     */
49    public function __construct(
50        ServiceOptions $options,
51        ILBFactory $dbLoadBalancerFactory,
52        NamespaceInfo $namespaceInfo,
53        TitleParser $titleParser,
54        LinkCache $linkCache,
55        StatsFactory $stats
56    ) {
57        $options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
58
59        $this->options = $options;
60        $this->dbLoadBalancerFactory = $dbLoadBalancerFactory;
61        $this->namespaceInfo = $namespaceInfo;
62        $this->titleParser = $titleParser;
63        $this->linkCache = $linkCache;
64        $this->stats = $stats;
65    }
66
67    /**
68     * @param string|false $wikiId
69     *
70     * @return PageStore
71     */
72    public function getPageStore( $wikiId = WikiAwareEntity::LOCAL ): PageStore {
73        return new PageStore(
74            $this->options,
75            $this->dbLoadBalancerFactory->getMainLB( $wikiId ),
76            $this->namespaceInfo,
77            $this->titleParser,
78            $wikiId !== WikiAwareEntity::LOCAL ? null : $this->linkCache,
79            $this->stats,
80            $wikiId
81        );
82    }
83
84}