protected function MailEntity::resetContext in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::resetContext()
 - 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 276  
Class
- MailEntity
 - Default mail class for entities.
 
Namespace
Drupal\simplenews\MailCode
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;
    }
  }
}