You are here

protected function Email::getPreferredLangcode in Search API Saved Searches 8

Retrieves the preferred langcode to use in mails for the given search.

Parameters

\Drupal\search_api_saved_searches\SavedSearchInterface $search: The saved search in question.

Return value

string The search's owner's preferred langcode, if one could be determined. The site default language otherwise.

3 calls to Email::getPreferredLangcode()
Email::getActivationMail in src/Plugin/search_api_saved_searches/notification/Email.php
Prepares a message for activating a new saved search.
Email::getNewResultsMail in src/Plugin/search_api_saved_searches/notification/Email.php
Prepares a message containing new saved search results.
Email::notify in src/Plugin/search_api_saved_searches/notification/Email.php
Notifies the search's owner of new results.

File

src/Plugin/search_api_saved_searches/notification/Email.php, line 522

Class

Email
Provides e-mails as a notification mechanism.

Namespace

Drupal\search_api_saved_searches\Plugin\search_api_saved_searches\notification

Code

protected function getPreferredLangcode(SavedSearchInterface $search) {
  $account = $search
    ->getOwner();
  if ($account) {
    return $account
      ->getPreferredLangcode();
  }
  return \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId();
}