mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #3982 from dhensby/pulls/safe-unnesting
Safe unnesting of Config and Injector
This commit is contained in:
commit
8e1da86bf1
@ -272,7 +272,16 @@ class Injector {
|
||||
* @return Injector Reference to restored active Injector instance
|
||||
*/
|
||||
public static function unnest() {
|
||||
return self::set_inst(self::$instance->nestedFrom);
|
||||
if (self::inst()->nestedFrom) {
|
||||
self::set_inst(self::inst()->nestedFrom);
|
||||
}
|
||||
else {
|
||||
user_error(
|
||||
"Unable to unnest root Injector, please make sure you don't have mis-matched nest/unnest",
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
return self::inst();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -237,7 +237,16 @@ class Config {
|
||||
* @return Config Reference to new active Config instance
|
||||
*/
|
||||
public static function unnest() {
|
||||
return self::set_instance(self::$instance->nestedFrom);
|
||||
if (self::inst()->nestedFrom) {
|
||||
self::set_instance(self::inst()->nestedFrom);
|
||||
}
|
||||
else {
|
||||
user_error(
|
||||
"Unable to unnest root Config, please make sure you don't have mis-matched nest/unnest",
|
||||
E_USER_WARNING
|
||||
);
|
||||
}
|
||||
return self::inst();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user