mirror of
https://github.com/silverstripe/silverstripe-subsites
synced 2024-10-22 11:05:55 +02:00
Merge pull request #321 from mikenz/resetable-state
Implement Resettable interface on SubsiteState so it gets reset between unit tests
This commit is contained in:
commit
0157bd0c05
@ -4,11 +4,12 @@ namespace SilverStripe\Subsites\State;
|
||||
|
||||
use SilverStripe\Core\Injector\Injectable;
|
||||
use SilverStripe\Core\Injector\Injector;
|
||||
use SilverStripe\Core\Resettable;
|
||||
|
||||
/**
|
||||
* SubsiteState provides static access to the current state for subsite related data during a request
|
||||
*/
|
||||
class SubsiteState
|
||||
class SubsiteState implements Resettable
|
||||
{
|
||||
use Injectable;
|
||||
|
||||
@ -106,4 +107,22 @@ class SubsiteState
|
||||
Injector::inst()->registerService($this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the local cache of the singleton
|
||||
*/
|
||||
public static function reset()
|
||||
{
|
||||
SubsiteState::singleton()->resetState();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the local cache of this object
|
||||
*/
|
||||
public function resetState()
|
||||
{
|
||||
$this->originalSubsiteId = null;
|
||||
$this->subsiteId = null;
|
||||
$this->useSessions = null;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user