interface AccountSwitcherInterface (View source)

Defines an interface for a service for safe account switching.

Methods

$this
switchTo(AccountInterface $account)

Safely switches to another account.

$this
switchBack()

Reverts to a previous account after switching.

Details

$this switchTo(AccountInterface $account)

Safely switches to another account.

Each invocation of AccountSwitcherInterface::switchTo() must be matched by a corresponding invocation of AccountSwitcherInterface::switchBack() in the same function.

Parameters

AccountInterface $account

The account to switch to.

Return Value

$this $this.

$this switchBack()

Reverts to a previous account after switching.

Return Value

$this $this.

Exceptions

RuntimeException