Manual:ContextSource.php
Arquivo MediaWiki: ContextSource.php | |
---|---|
Local: | includes/context/ |
Código fonte: | master • 1.42.3 • 1.41.4 • 1.39.10 |
Classes: | MediaWiki\Context\ContextSource |
ContextSource is an abstract class that holds request-dependent objects containers.
It implements IContextSource.
Public methods
- getContext()
- setContext()
- etc.
Extended by
Notes
From a ContextSource class you can use setContext() to set the context your class is in. For example a constructor that requires a context can be written like so:
class SomeClass extends ContextSource {
public function __constructor( IContextSource $context ) {
$this->setContext( $context );
}
}
Because we cannot use traits[1] yet if you need to make your class extend from another class you will have to implements IContextSource
and implement the helper boilerplate directly in the class.
Again if you can't extend ContextSource you'll have to write the helper boilerplate into your class directly. As we unfortunately cannot use traits[1] to allow something like this:
class SomeClass extends SomeOtherClass implements IContextSource {
use TContextSource;
public function __constructor( IContextSource $context ) {
$this->setContext( $context );
}
}