trait AccountSwitcherTrait in Tome 8
Shared methods for handling account switching.
Hierarchy
- trait \Drupal\tome_sync\AccountSwitcherTrait
File
- modules/
tome_sync/ src/ AccountSwitcherTrait.php, line 10
Namespace
Drupal\tome_syncView source
trait AccountSwitcherTrait {
/**
* The account switcher.
*
* @var \Drupal\Core\Session\AccountSwitcherInterface
*/
protected $accountSwitcher;
/**
* Switches the current user to the admin.
*/
protected function switchToAdmin() {
$this->accountSwitcher
->switchTo(new UserSession([
'uid' => 1,
]));
}
/**
* Switches the current user back.
*/
protected function switchBack() {
$this->accountSwitcher
->switchBack();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AccountSwitcherTrait:: |
protected | property | The account switcher. | |
AccountSwitcherTrait:: |
protected | function | Switches the current user back. | |
AccountSwitcherTrait:: |
protected | function | Switches the current user to the admin. |