2021-03-17 22:13:35 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace MediaWiki\Page;
|
|
|
|
|
|
2024-02-08 19:09:50 +00:00
|
|
|
use MediaWiki\Cache\LinkCache;
|
2021-03-17 22:13:35 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
|
|
|
|
use MediaWiki\DAO\WikiAwareEntity;
|
2023-09-18 14:17:28 +00:00
|
|
|
use MediaWiki\Title\NamespaceInfo;
|
2023-09-18 14:35:57 +00:00
|
|
|
use MediaWiki\Title\TitleParser;
|
2021-03-17 22:13:35 +00:00
|
|
|
use Wikimedia\Rdbms\ILBFactory;
|
2024-05-04 12:39:45 +00:00
|
|
|
use Wikimedia\Stats\StatsFactory;
|
2021-03-17 22:13:35 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @since 1.36
|
|
|
|
|
*/
|
|
|
|
|
class PageStoreFactory {
|
|
|
|
|
|
|
|
|
|
/**
|
2022-04-08 15:13:15 +00:00
|
|
|
* @internal For use by service wiring
|
2021-03-17 22:13:35 +00:00
|
|
|
*/
|
|
|
|
|
public const CONSTRUCTOR_OPTIONS = PageStore::CONSTRUCTOR_OPTIONS;
|
|
|
|
|
|
2024-06-10 20:49:30 +00:00
|
|
|
private ServiceOptions $options;
|
|
|
|
|
private ILBFactory $dbLoadBalancerFactory;
|
|
|
|
|
private NamespaceInfo $namespaceInfo;
|
|
|
|
|
private TitleParser $titleParser;
|
|
|
|
|
private LinkCache $linkCache;
|
|
|
|
|
private StatsFactory $stats;
|
2021-03-17 22:13:35 +00:00
|
|
|
|
|
|
|
|
public function __construct(
|
|
|
|
|
ServiceOptions $options,
|
|
|
|
|
ILBFactory $dbLoadBalancerFactory,
|
2021-05-04 20:45:30 +00:00
|
|
|
NamespaceInfo $namespaceInfo,
|
2021-06-01 20:14:36 +00:00
|
|
|
TitleParser $titleParser,
|
|
|
|
|
LinkCache $linkCache,
|
2024-05-04 12:39:45 +00:00
|
|
|
StatsFactory $stats
|
2021-03-17 22:13:35 +00:00
|
|
|
) {
|
|
|
|
|
$options->assertRequiredOptions( self::CONSTRUCTOR_OPTIONS );
|
|
|
|
|
|
|
|
|
|
$this->options = $options;
|
|
|
|
|
$this->dbLoadBalancerFactory = $dbLoadBalancerFactory;
|
|
|
|
|
$this->namespaceInfo = $namespaceInfo;
|
2021-05-04 20:45:30 +00:00
|
|
|
$this->titleParser = $titleParser;
|
2021-06-01 20:14:36 +00:00
|
|
|
$this->linkCache = $linkCache;
|
|
|
|
|
$this->stats = $stats;
|
2021-03-17 22:13:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param string|false $wikiId
|
|
|
|
|
*
|
|
|
|
|
* @return PageStore
|
|
|
|
|
*/
|
|
|
|
|
public function getPageStore( $wikiId = WikiAwareEntity::LOCAL ): PageStore {
|
|
|
|
|
return new PageStore(
|
|
|
|
|
$this->options,
|
|
|
|
|
$this->dbLoadBalancerFactory->getMainLB( $wikiId ),
|
|
|
|
|
$this->namespaceInfo,
|
2021-05-04 20:45:30 +00:00
|
|
|
$this->titleParser,
|
2021-06-01 20:14:36 +00:00
|
|
|
$wikiId !== WikiAwareEntity::LOCAL ? null : $this->linkCache,
|
|
|
|
|
$this->stats,
|
2021-03-17 22:13:35 +00:00
|
|
|
$wikiId
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|