yii\base\Module::setInstance PHP Method

setInstance() public static method

Sets the currently requested instance of this module class.
public static setInstance ( Module | null $instance )
$instance Module | null the currently requested instance of this module class. If it is `null`, the instance of the calling class will be removed, if any.
    public static function setInstance($instance)
    {
        if ($instance === null) {
            unset(Yii::$app->loadedModules[get_called_class()]);
        } else {
            Yii::$app->loadedModules[get_class($instance)] = $instance;
        }
    }