Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. AccountSwitcherInterface.php

function AccountSwitcherInterface::switchTo

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

\Drupal\Core\Session\AccountInterface $account: The account to switch to.

Return value

$this $this.

2 methods override AccountSwitcherInterface::switchTo()
AccountSwitcher::switchTo in core/lib/Drupal/Core/Session/AccountSwitcher.php
Safely switches to another account.
AdminAccountSwitcher::switchTo in core/lib/Drupal/Core/DefaultContent/AdminAccountSwitcher.php
Safely switches to another account.

File

core/lib/Drupal/Core/Session/AccountSwitcherInterface.php, line 25

Class

AccountSwitcherInterface
Defines an interface for a service for safe account switching.

Namespace

Drupal\Core\Session

Code

public function switchTo(AccountInterface $account);

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal