This is a hook handler interface, see docs/Hooks.md.
More...
Inherited by MediaWiki\HookContainer\HookRunner.
|
| onMediaWikiServices ( $services) |
| This hook is called when a global MediaWikiServices instance is initialized.
|
|
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.
- Stability: stable
- to implement
Definition at line 19 of file MediaWikiServicesHook.php.
◆ onMediaWikiServices()
MediaWiki\Hook\MediaWikiServicesHook::onMediaWikiServices |
( |
| $services | ) |
|
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:
function onMediaWikiServices( $services ) {
$services->defineService(
'MyCoolService',
return new MyCoolService( $container->getPageLookup() );
}
);
$services->addServiceManipulator(
'SlotRoleRegistry',
}
);
$services->redefineService(
'StatsdDataFactory',
}
);
}
- Since
- 1.35
- Parameters
-
MediaWikiServices | $services | |
- Returns
- bool|void True or no return value to continue or false to abort
Implemented in MediaWiki\HookContainer\HookRunner.
The documentation for this interface was generated from the following file: