You are here

class AccountSwitcherDecorator in Acquia Content Hub 8

Extend current account switcher service functionality.

@package Drupal\acquia_contenthub

Hierarchy

Expanded class hierarchy of AccountSwitcherDecorator

1 string reference to 'AccountSwitcherDecorator'
acquia_contenthub.services.yml in ./acquia_contenthub.services.yml
acquia_contenthub.services.yml
1 service uses AccountSwitcherDecorator
acquia_contenthub.account_switcher.decorator in ./acquia_contenthub.services.yml
Drupal\acquia_contenthub\AccountSwitcherDecorator

File

src/AccountSwitcherDecorator.php, line 12

Namespace

Drupal\acquia_contenthub
View source
class AccountSwitcherDecorator extends AccountSwitcher {

  /**
   * Switch back only if account stack contains at least one account.
   */
  public function switchBack() {

    // If there are no more accounts in the account stack,
    // current user will be the original user.
    if (count($this->accountStack) !== 0) {
      parent::switchBack();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AccountSwitcher::$accountStack protected property A stack of previous overridden accounts.
AccountSwitcher::$currentUser protected property The current user service.
AccountSwitcher::$originalSessionSaving protected property The original state of session saving prior to account switching.
AccountSwitcher::$writeSafeHandler protected property The write-safe session handler.
AccountSwitcher::switchTo public function Safely switches to another account. Overrides AccountSwitcherInterface::switchTo
AccountSwitcher::__construct public function Constructs a new AccountSwitcher.
AccountSwitcherDecorator::switchBack public function Switch back only if account stack contains at least one account. Overrides AccountSwitcher::switchBack