You are here

class QueueMailLanguageNegotiator in Queue Mail 8

Class responsible for performing language negotiation.

Hierarchy

Expanded class hierarchy of QueueMailLanguageNegotiator

1 file declares its use of QueueMailLanguageNegotiator
LanguageAwareSendMailQueueWorker.php in modules/queue_mail_language/src/Plugin/QueueWorker/LanguageAwareSendMailQueueWorker.php
1 string reference to 'QueueMailLanguageNegotiator'
queue_mail_language.services.yml in modules/queue_mail_language/queue_mail_language.services.yml
modules/queue_mail_language/queue_mail_language.services.yml
1 service uses QueueMailLanguageNegotiator
queue_mail.language_negotiator in modules/queue_mail_language/queue_mail_language.services.yml
Drupal\queue_mail_language\QueueMailLanguageNegotiator

File

modules/queue_mail_language/src/QueueMailLanguageNegotiator.php, line 10

Namespace

Drupal\queue_mail_language
View source
class QueueMailLanguageNegotiator extends LanguageNegotiator {

  /**
   * Language code.
   *
   * @var string
   */
  public $languageCode = NULL;

  /**
   * {@inheritdoc}
   */
  public function initializeType($type) {
    $language = NULL;
    $method_id = static::METHOD_ID;
    $availableLanguages = $this->languageManager
      ->getLanguages();
    if ($this->languageCode && isset($availableLanguages[$this->languageCode])) {
      $language = $availableLanguages[$this->languageCode];
    }
    else {

      // If no other language was found use the default one.
      $language = $this->languageManager
        ->getDefaultLanguage();
    }
    return [
      $method_id => $language,
    ];
  }

  /**
   * Sets language code.
   *
   * @param string $langcode
   *   Language code.
   */
  public function setLanguageCode($langcode) {
    $this->languageCode = $langcode;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
LanguageNegotiator::$configFactory protected property The configuration factory.
LanguageNegotiator::$currentUser protected property The current active user.
LanguageNegotiator::$languageManager protected property The language manager.
LanguageNegotiator::$methods protected property Local cache for language negotiation method instances.
LanguageNegotiator::$negotiatedLanguages protected property An array of language objects keyed by method id.
LanguageNegotiator::$negotiatorManager protected property The language negotiation method plugin manager.
LanguageNegotiator::$requestStack protected property The request stack object.
LanguageNegotiator::$settings protected property The settings instance.
LanguageNegotiator::getEnabledNegotiators protected function Gets enabled detection methods for the provided language type.
LanguageNegotiator::getNegotiationMethodInstance public function Returns an instance of the specified language negotiation method. Overrides LanguageNegotiatorInterface::getNegotiationMethodInstance
LanguageNegotiator::getNegotiationMethods public function Returns the language negotiation methods enabled for a language type. Overrides LanguageNegotiatorInterface::getNegotiationMethods
LanguageNegotiator::getPrimaryNegotiationMethod public function Returns the ID of the language type's primary language negotiation method. Overrides LanguageNegotiatorInterface::getPrimaryNegotiationMethod
LanguageNegotiator::initLanguageManager public function Initializes the injected language manager with the negotiator.
LanguageNegotiator::isNegotiationMethodEnabled public function Checks whether a language negotiation method is enabled for a language type. Overrides LanguageNegotiatorInterface::isNegotiationMethodEnabled
LanguageNegotiator::negotiateLanguage protected function Performs language negotiation using the specified negotiation method.
LanguageNegotiator::purgeConfiguration public function Resave the configuration to purge missing negotiation methods. Overrides LanguageNegotiatorInterface::purgeConfiguration
LanguageNegotiator::reset public function Resets the negotiated languages and the method instances. Overrides LanguageNegotiatorInterface::reset
LanguageNegotiator::saveConfiguration public function Saves a list of language negotiation methods for a language type. Overrides LanguageNegotiatorInterface::saveConfiguration
LanguageNegotiator::setCurrentUser public function Sets the current active user and resets all language types. Overrides LanguageNegotiatorInterface::setCurrentUser
LanguageNegotiator::updateConfiguration public function Updates the configuration based on the given language types. Overrides LanguageNegotiatorInterface::updateConfiguration
LanguageNegotiator::__construct public function Constructs a new LanguageNegotiator object.
LanguageNegotiatorInterface::METHOD_ID constant The language negotiation method id for the language negotiator itself.
QueueMailLanguageNegotiator::$languageCode public property Language code.
QueueMailLanguageNegotiator::initializeType public function Initializes the specified language type. Overrides LanguageNegotiator::initializeType
QueueMailLanguageNegotiator::setLanguageCode public function Sets language code.