hookContainer = MediaWikiServices::getInstance()->getHookContainer(); } /** * @since 2.0 * * @return MwHooksHandler */ public function deregisterListedHooks() { $listOfHooks = array_merge( $this->listOfSmwHooks, $this->getHookRegistry()->getHandlerList() ); foreach ( $listOfHooks as $hook ) { if ( $this->hookContainer->isRegistered( $hook ) ) { $this->hookContainer->clear( $hook ); } } return $this; } /** * @since 2.0 * * @return MwHooksHandler */ public function restoreListedHooks() { foreach ( $this->inTestRegisteredHooks as $hook ) { $this->hookContainer->clear( $hook ); } foreach ( $this->wgHooks as $hook => $definition ) { $this->hookContainer->register( $hook, $definition ); unset( $this->wgHooks[$hook] ); } return $this; } /** * @since 2.1 * * @return MwHooksHandler */ public function register( $name, callable $callback ) { $listOfHooks = array_merge( $this->listOfSmwHooks, $this->getHookRegistry()->getHandlerList() ); if ( !in_array( $name, $listOfHooks ) ) { throw new RuntimeException( "$name is not listed as registrable hook" ); } $this->inTestRegisteredHooks[] = $name; $this->hookContainer->register( $name, $callback ); return $this; } public function invokeHooksFromRegistry() { $this->getHookRegistry()->register(); return $this; } /** * @since 2.1 * * @return Hooks */ public function getHookRegistry(): Hooks { if ( $this->hookRegistry === null ) { $this->hookRegistry = new Hooks(); } return $this->hookRegistry; } }