summaryrefslogtreecommitdiff
blob: 6c43790b7d9aa0bc14cb02945aeebd5f78a0cbcf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 * Cache class that maps article id to Title object
 */
class EchoTitleLocalCache extends EchoLocalCache {

	/**
	 * @var EchoTitleLocalCache
	 */
	private static $instance;

	/**
	 * Create a TitleLocalCache object
	 * @return EchoTitleLocalCache
	 */
	public static function create() {
		if ( !self::$instance ) {
			self::$instance = new EchoTitleLocalCache();
		}

		return self::$instance;
	}

	/**
	 * @inheritDoc
	 */
	protected function resolve() {
		if ( $this->lookups ) {
			$titles = Title::newFromIDs( $this->lookups );
			foreach ( $titles as $title ) {
				$this->targets->set( $title->getArticleId(), $title );
			}
			$this->lookups = [];
		}
	}

}