Debian Codegraph @

includes/HookContainer/ProtectedHookAccessorTrait.php

raw symbols SCIP
1 <?php
2
3 namespace MediaWiki\HookContainer;
4
5 use MediaWiki\MediaWikiServices;
6
7 /**
8 * This trait provides an implementation of getHookContainer() and
9 * getHookRunner() for classes that do not use dependency injection. Its
10 * purpose is to provide a consistent API which can easily be maintained
11 * after the class has been migrated to dependency injection.
12 */
13 trait ProtectedHookAccessorTrait {
14 /**
15 * Get a HookContainer, for running extension hooks or for hook metadata.
16 *
17 * @since 1.35
18 * @return HookContainer
19 */
20 protected function getHookContainer() {
21 return MediaWikiServices::getInstance()->getHookContainer();
22 }
23
24 /**
25 * Get a HookRunner for running core hooks.
26 *
27 * @internal This is for use by core only. Hook interfaces may be removed
28 * without notice.
29 * @since 1.35
30 * @return HookRunner
31 */
32 protected function getHookRunner() {
33 return new HookRunner( $this->getHookContainer() );
34 }
35 }