Debian Codegraph @

extensions/Echo/includes/Cache/TitleLocalCache.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\Extension\Notifications\Cache;
4
5 use MediaWiki\Page\PageRecord;
6 use MediaWiki\Page\PageStore;
7 use MediaWiki\Title\TitleFactory;
8
9 /**
10 * Cache class that maps article id to Title object.
11 * @fixme There should be no need for this class. Core's PageStore should be responsible for caching, if it's
12 * deemed necessary. See also T344124.
13 */
14 class TitleLocalCache extends LocalCache {
15 private PageStore $pageStore;
16 private TitleFactory $titleFactory;
17
18 public function __construct(
19 PageStore $pageStore,
20 TitleFactory $titleFactory
21 ) {
22 parent::__construct();
23 $this->pageStore = $pageStore;
24 $this->titleFactory = $titleFactory;
25 }
26
27 /**
28 * @inheritDoc
29 */
30 protected function resolve( array $lookups ) {
31 if ( $lookups ) {
32 $titles = $this->pageStore
33 ->newSelectQueryBuilder()
34 ->wherePageIds( $lookups )
35 ->caller( __METHOD__ )
36 ->fetchPageRecords();
37
38 /** @var PageRecord $title */
39 foreach ( $titles as $title ) {
40 $title = $this->titleFactory->castFromPageIdentity( $title );
41 yield $title->getArticleID() => $title;
42 }
43 }
44 }
45
46 }