summaryrefslogtreecommitdiff
blob: d94d9855c1617f2f50f7a48450d57b9bf350d433 (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
<?php

namespace MediaWiki\CheckUser;

use EventLogging;
use ExtensionRegistry;

class EventLogger {
	/** @var ExtensionRegistry */
	private $extensionRegistry;

	/**
	 * @param ExtensionRegistry $extensionRegistry
	 */
	public function __construct(
		ExtensionRegistry $extensionRegistry
	) {
		$this->extensionRegistry = $extensionRegistry;
	}

	/**
	 * Log an event using the SpecialInvestigate schema.
	 *
	 * @param array $event
	 */
	public function logEvent( $event ) : void {
		if ( $this->extensionRegistry->isLoaded( 'EventLogging' ) ) {
			EventLogging::logEvent(
				'SpecialInvestigate',
				// Revision ID of the schema - keep this in sync with extension.json
				20261100,
				$event
			);
		}
	}

	/**
	 * Get a timestamp in milliseconds.
	 *
	 * @return int
	 */
	public function getTime() : int {
		return (int)round( microtime( true ) * 1000 );
	}
}