summaryrefslogtreecommitdiff
blob: 7de038117cb1cbb71da22b3cc5c6180479f244f8 (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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<?php

class UserMergeLogFormatter extends LogFormatter {

	private static $mapLegacy = [
		'oldName' => 0,
		'oldId' => 1,
		'newName' => 2,
		'newId' => 3,
	];

	/**
	 * @return string
	 */
	protected function getMessageKey() {
		if ( $this->entry->getSubtype() === 'deleteuser' ) {
			return 'logentry-usermerge-deleteuser';
		} else {
			return 'logentry-usermerge-mergeuser';
		}
	}

	/**
	 * @param string $param
	 * @return mixed
	 */
	private function getParameter( $param ) {
		$parameters = $this->entry->getParameters();
		if ( $this->entry->isLegacy() ) {
			$param = self::$mapLegacy[$param];
		}
		return $parameters[$param];
	}

	/**
	 * @return array
	 */
	protected function extractParameters() {
		$params = [];
		// 0-2 are set in LogFormatter::getMessageParameters()
		$params[3] = $this->getParameter( 'oldName' );
		$params[4] = $this->getParameter( 'oldId' );
		if ( $this->entry->getSubtype() !== 'deleteuser' ) {
			$params[5] = $this->formatParameterValue(
				'user-link', $this->getParameter( 'newName' ) );
			$params[6] = $this->getParameter( 'newId' );
			$params[7] = $this->formatParameterValue(
				'user', $this->getParameter( 'newName' ) );
		}
		return $params;
	}

}