public function AccountSwitcher::switchBack
public AccountSwitcher::switchBack()
Reverts to a previous account after switching.
Return value
\Drupal\Core\Session\AccountSwitcherInterface $this.
Throws
\RuntimeException When there are no more account switches to revert.
Overrides AccountSwitcherInterface::switchBack
File
- core/lib/Drupal/Core/Session/AccountSwitcher.php, line 73
Class
- AccountSwitcher
- An implementation of AccountSwitcherInterface.
Namespace
Drupal\Core\SessionCode
public function switchBack() { // Restore the previous account from the stack. if (!empty($this->accountStack)) { $this->currentUser->setAccount(array_pop($this->accountStack)); } else { throw new \RuntimeException('No more accounts to revert to.'); } // Restore original session saving status if all account switches are // reverted. if (empty($this->accountStack)) { if ($this->originalSessionSaving) { $this->writeSafeHandler->setSessionWritable(TRUE); } } return $this; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Session!AccountSwitcher.php/function/AccountSwitcher::switchBack/8.1.x