You are here

protected function MailEntity::resetContext in Simplenews 8.2

Same name and namespace in other branches
  1. 8 src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::resetContext()
  2. 3.x src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::resetContext()

Reset the context.

1 call to MailEntity::resetContext()
MailEntity::getBodyWithFormat in src/Mail/MailEntity.php
Get the body with the requested format.

File

src/Mail/MailEntity.php, line 259

Class

MailEntity
Default mail class for entities.

Namespace

Drupal\simplenews\Mail

Code

protected function resetContext() {

  // Switch back to the previous user.
  if ($this->uid) {
    \Drupal::service('account_switcher')
      ->switchBack();
  }

  // Switch language back.
  if (!empty($this->original_language)) {
    $GLOBALS['language'] = $this->original_language;
    $GLOBALS['language_url'] = $this->original_language;
    if (\Drupal::moduleHandler()
      ->moduleExists('i18n_select')) {
      $GLOBALS['language_content'] = $this->original_language;
    }
  }
}