public function MockFileSessionStorage::save in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/http-foundation/Session/Storage/MockFileSessionStorage.php \Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage::save()
Force the session to be saved and closed.
This method must invoke session_write_close() unless this interface is used for a storage object design for unit or functional testing where a real PHP session would interfere with testing, in which case it it should actually persist the session data if required.
Throws
\RuntimeException If the session is saved without being started, or if the session is already closed.
Overrides MockArraySessionStorage::save
File
- vendor/
symfony/ http-foundation/ Session/ Storage/ MockFileSessionStorage.php, line 93
Class
- MockFileSessionStorage
- MockFileSessionStorage is used to mock sessions for functional testing when done in a single PHP process.
Namespace
Symfony\Component\HttpFoundation\Session\StorageCode
public function save() {
if (!$this->started) {
throw new \RuntimeException('Trying to save a session that was not started yet or was already closed');
}
file_put_contents($this
->getFilePath(), serialize($this->data));
// this is needed for Silex, where the session object is re-used across requests
// in functional tests. In Symfony, the container is rebooted, so we don't have
// this issue
$this->started = false;
}