1<?php 2 3namespace MediaWiki\HookContainer; 4 5use ExtensionRegistry; 6 7/** 8 * A HookRegistry which sources its data from dynamically changing sources: 9 * $wgHooks and an ExtensionRegistry. 10 */ 11class GlobalHookRegistry implements HookRegistry { 12 /** @var ExtensionRegistry */ 13 private $extensionRegistry; 14 /** @var DeprecatedHooks */ 15 private $deprecatedHooks; 16 17 public function __construct( 18 ExtensionRegistry $extensionRegistry, 19 DeprecatedHooks $deprecatedHooks 20 ) { 21 $this->extensionRegistry = $extensionRegistry; 22 $this->deprecatedHooks = $deprecatedHooks; 23 } 24 25 public function getGlobalHooks() { 26 global $wgHooks; 27 return $wgHooks; 28 } 29 30 public function getExtensionHooks() { 31 return $this->extensionRegistry->getAttribute( 'Hooks' ) ?? []; 32 } 33 34 public function getDeprecatedHooks() { 35 return $this->deprecatedHooks; 36 } 37} 38