mediawiki-extensions-Echo/includes/Cache/TitleLocalCache.php
thiemowmde 2a4f186400 Remove obsolete PHPDoc copies from fully typed constructors
It's all in the code now. These comments don't add anything any
more.

Change-Id: I66a3723c4fe9ccce989f5b533390d5ce928dc195
2024-08-11 18:05:01 +02:00

47 lines
1.1 KiB
PHP

<?php
namespace MediaWiki\Extension\Notifications\Cache;
use MediaWiki\Page\PageRecord;
use MediaWiki\Page\PageStore;
use MediaWiki\Title\TitleFactory;
/**
* Cache class that maps article id to Title object.
* @fixme There should be no need for this class. Core's PageStore should be responsible for caching, if it's
* deemed necessary. See also T344124.
*/
class TitleLocalCache extends LocalCache {
private PageStore $pageStore;
private TitleFactory $titleFactory;
public function __construct(
PageStore $pageStore,
TitleFactory $titleFactory
) {
parent::__construct();
$this->pageStore = $pageStore;
$this->titleFactory = $titleFactory;
}
/**
* @inheritDoc
*/
protected function resolve( array $lookups ) {
if ( $lookups ) {
$titles = $this->pageStore
->newSelectQueryBuilder()
->wherePageIds( $lookups )
->caller( __METHOD__ )
->fetchPageRecords();
/** @var PageRecord $title */
foreach ( $titles as $title ) {
$title = $this->titleFactory->castFromPageIdentity( $title );
yield $title->getArticleID() => $title;
}
}
}
}