StaticInstanceInterface
API reference › yii › base › StaticInstanceInterface
Implemented by 2 types
StaticInstanceInterface is the interface for providing static instances to classes, which can be used to obtain class meta information that can not be expressed in static methods.
For example: adjustments made by DI or behaviors reveal only at object level, but might be needed at class (static) level as well.
To implement the instance() method you may use StaticInstanceTrait.
See also: StaticInstanceTrait.
Methods
Section titled “Methods”| Method | Description | Defined by |
|---|---|---|
instance() static abstract | Returns static class instance, which can be used to obtain meta information. | StaticInstanceInterface |
Method details
Section titled “Method details”instance()
Section titled “instance() ”abstract public static function instance(bool $refresh = false): staticReturns static class instance, which can be used to obtain meta information.
Parameters
| Parameter | Type | Description |
|---|---|---|
$refresh | bool | Whether to re-create static instance even, if it is already cached. |
Returns
static: Class instance.