Podręcznik:DerivativeContext.php
Appearance
| Wersja MediaWiki: | ≥ 1.19 |
| Plik MediaWiki: DerivativeContext.php | |
|---|---|
| Lokalizacja: | includes/context/ (includes/Context/ in 1.46 or later) |
| Kod źródłowy: | master • 1.45.1 • 1.44.3 • 1.43.6 |
| Klasy: | MediaWiki\Context\DerivativeContext |
The DerivativeContext class is used to inherit the context from another source while still allowing the individual pieces of the context, such as a Title instance, to be changed locally.
It extends ContextSource and implements the MutableContext interface.
Instantiation
Example:
$newContext = new DerivativeContext( $currentContext );
$newContext->setTitle( Title::newFromText( 'Asdf' ) );
Note
When designing a class API it is preferable to just use a ContextSource and not require a separate Title (or by extension WikiPage) as an argument. As the calling API would be better off making use of a DerivativeContext if it needs to pass a different context to your class API.