File: MediaWikiServicesHook.php

package info (click to toggle)
mediawiki 1%3A1.43.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 417,464 kB
  • sloc: php: 1,062,949; javascript: 664,290; sql: 9,714; python: 5,458; xml: 3,489; sh: 1,131; makefile: 64
file content (68 lines) | stat: -rw-r--r-- 2,436 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php

namespace MediaWiki\Hook;

use MediaWiki\MediaWikiServices;

/**
 * This is a hook handler interface, see docs/Hooks.md.
 * Use the hook name "MediaWikiServices" to register handlers implementing this interface.
 *
 * @warning Implementations of this interface must not have services injected into
 * their constructor! This is because this hook runs while the service container is
 * still being initialized, so any services it asks for might get instantiated based on
 * incomplete configuration and wiring.
 *
 * @stable to implement
 * @ingroup Hooks
 */
interface MediaWikiServicesHook {
	/**
	 * This hook is called when a global MediaWikiServices instance is initialized.
	 * Extensions may use this to define, replace, or wrap services. However, the
	 * preferred way to define a new service is the $wgServiceWiringFiles array.
	 *
	 * @warning Implementations must not immediately access services instances from the
	 * service container $services, since the service container is not fully initialized
	 * at the time when the hook is called. However, callbacks that are used as service
	 * instantiators or service manipulators may access service instances.
	 *
	 * Example:
	 * @code
	 * function onMediaWikiServices( $services ) {
	 *     // The service wiring and configuration in $services may be incomplete at this time,
	 *     // do not access services yet!
	 *     // At this point, we can only manipulate the wiring, not use it!
	 *
	 *     $services->defineService(
	 *        'MyCoolService',
	 *         function( MediaWikiServices $container ) {
	 *             // It's ok to access services inside this callback, since the
	 *             // service container will be fully initialized when it is called!
	 *             return new MyCoolService( $container->getPageLookup() );
	 *         }
	 *     );
	 *
	 *     $services->addServiceManipulator(
	 *         'SlotRoleRegistry',
	 *         function ( SlotRoleRegistry $service, MediaWikiServices $container ) {
	 *             // ...
	 *         }
	 *     );
	 *
	 *     $services->redefineService(
	 *         'StatsdDataFactory',
	 *         function ( MediaWikiServices $container ) {
	 *             // ...
	 *         }
	 *     );
	 * }
	 * @endcode
	 *
	 * @since 1.35
	 *
	 * @param MediaWikiServices $services
	 * @return bool|void True or no return value to continue or false to abort
	 */
	public function onMediaWikiServices( $services );
}