Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| StaticHookRegistry | |
100.00% |
4 / 4 |
|
100.00% |
4 / 4 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getGlobalHooks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getExtensionHooks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getDeprecatedHooks | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\HookContainer; |
| 4 | |
| 5 | /** |
| 6 | * This is a simple immutable HookRegistry which can be used to set up a local |
| 7 | * HookContainer in tests and for similar purposes. |
| 8 | */ |
| 9 | class StaticHookRegistry implements HookRegistry { |
| 10 | private readonly DeprecatedHooks $deprecatedHooks; |
| 11 | |
| 12 | /** |
| 13 | * @param array $globalHooks An array of legacy hooks in the same format as $wgHooks |
| 14 | * @param array $extensionHooks An array of modern hooks in the format |
| 15 | * described in HookRegistry::getExtensionHooks() |
| 16 | * @param array $deprecatedHooksArray An array of deprecated hooks in the |
| 17 | * format expected by DeprecatedHooks::__construct(). These hooks are added |
| 18 | * to the core deprecated hooks list which is always present. |
| 19 | */ |
| 20 | public function __construct( |
| 21 | private readonly array $globalHooks = [], |
| 22 | private readonly array $extensionHooks = [], |
| 23 | array $deprecatedHooksArray = [], |
| 24 | ) { |
| 25 | $this->deprecatedHooks = new DeprecatedHooks( $deprecatedHooksArray ); |
| 26 | } |
| 27 | |
| 28 | /** @inheritDoc */ |
| 29 | public function getGlobalHooks() { |
| 30 | return $this->globalHooks; |
| 31 | } |
| 32 | |
| 33 | /** @inheritDoc */ |
| 34 | public function getExtensionHooks() { |
| 35 | return $this->extensionHooks; |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * @return DeprecatedHooks |
| 40 | */ |
| 41 | public function getDeprecatedHooks() { |
| 42 | return $this->deprecatedHooks; |
| 43 | } |
| 44 | } |