aboutsummaryrefslogtreecommitdiffstats
path: root/includes/HookContainer/StaticHookRegistry.php
blob: 592514928ef07ebc33b09fb168901f191ccf501a (plain) (blame)
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
<?php

namespace MediaWiki\HookContainer;

/**
 * This is a simple immutable HookRegistry which can be used to set up a local
 * HookContainer in tests and for similar purposes.
 */
class StaticHookRegistry implements HookRegistry {
	/** @var array */
	private $globalHooks;

	/** @var array */
	private $extensionHooks;

	/** @var DeprecatedHooks */
	private $deprecatedHooks;

	/**
	 * @param array $globalHooks An array of legacy hooks in the same format as $wgHooks
	 * @param array $extensionHooks An array of modern hooks in the format
	 *   described in HookRegistry::getExtensionHooks()
	 * @param array $deprecatedHooksArray An array of deprecated hooks in the
	 *   format expected by DeprecatedHooks::__construct(). These hooks are added
	 *   to the core deprecated hooks list which is always present.
	 */
	public function __construct(
		array $globalHooks = [],
		array $extensionHooks = [],
		array $deprecatedHooksArray = []
	) {
		$this->globalHooks = $globalHooks;
		$this->extensionHooks = $extensionHooks;
		$this->deprecatedHooks = new DeprecatedHooks( $deprecatedHooksArray );
	}

	public function getGlobalHooks() {
		return $this->globalHooks;
	}

	public function getExtensionHooks() {
		return $this->extensionHooks;
	}

	/**
	 * @return DeprecatedHooks
	 */
	public function getDeprecatedHooks() {
		return $this->deprecatedHooks;
	}
}