class LanguageAwareSendMailQueueWorker in Queue Mail 8
Sends emails from queue with language support.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
- class \Drupal\queue_mail\Plugin\QueueWorker\SendMailQueueWorker implements ContainerFactoryPluginInterface uses StringTranslationTrait
- class \Drupal\queue_mail_language\Plugin\QueueWorker\LanguageAwareSendMailQueueWorker
- class \Drupal\queue_mail\Plugin\QueueWorker\SendMailQueueWorker implements ContainerFactoryPluginInterface uses StringTranslationTrait
- class \Drupal\Core\Queue\QueueWorkerBase implements QueueWorkerInterface
Expanded class hierarchy of LanguageAwareSendMailQueueWorker
1 file declares its use of LanguageAwareSendMailQueueWorker
- queue_mail_language.module in modules/
queue_mail_language/ queue_mail_language.module - The Queue Mail Language module.
File
- modules/
queue_mail_language/ src/ Plugin/ QueueWorker/ LanguageAwareSendMailQueueWorker.php, line 20
Namespace
Drupal\queue_mail_language\Plugin\QueueWorkerView source
class LanguageAwareSendMailQueueWorker extends SendMailQueueWorker {
/**
* The configurable language manager.
*
* @var \Drupal\language\ConfigurableLanguageManagerInterface
*/
protected $languageManager;
/**
* The queue mail language negotiator.
*
* @var \Drupal\queue_mail_language\QueueMailLanguageNegotiator
*/
protected $queueMailLanguageNegotiator;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($container
->get('theme.manager'), $container
->get('theme.initialization'), $container
->get('plugin.manager.mail'), $container
->get('logger.factory'), $container
->get('config.factory'), $container
->get('queue'), $container
->get('module_handler'), $container
->get('language_manager'), $container
->get('queue_mail.language_negotiator'));
}
/**
* {@inheritdoc}
*/
public function __construct(ThemeManagerInterface $theme_manager, ThemeInitializationInterface $theme_init, MailManagerInterface $mail_manager, LoggerChannelFactoryInterface $logger_factory, ConfigFactoryInterface $config_factory, ContainerAwareInterface $queue_factory, ModuleHandlerInterface $module_handler, ConfigurableLanguageManagerInterface $language_manager, QueueMailLanguageNegotiator $queue_mail_language_negotiator) {
parent::__construct($theme_manager, $theme_init, $mail_manager, $logger_factory, $config_factory, $queue_factory, $module_handler);
$this->languageManager = $language_manager;
$this->queueMailLanguageNegotiator = $queue_mail_language_negotiator;
}
/**
* {@inheritdoc}
*/
protected function setMailLanguage(array $message) {
$default_langcode = $this->languageManager
->getDefaultLanguage()
->getId();
if ($message['langcode'] !== $default_langcode) {
$this
->setNegotiatorLanguage($message['langcode']);
}
return $default_langcode;
}
/**
* {@inheritdoc}
*/
protected function setActiveLanguage(array $message, $langcode) {
if ($message['langcode'] !== $langcode) {
$this
->setNegotiatorLanguage($langcode);
}
}
/**
* Sets the queue mail negotiator language.
*
* @param string $langcode
* The new language code.
*/
protected function setNegotiatorLanguage($langcode) {
if ($this->languageManager
->getNegotiator() !== $this->queueMailLanguageNegotiator) {
$this->languageManager
->setNegotiator($this->queueMailLanguageNegotiator);
}
$this->queueMailLanguageNegotiator
->setLanguageCode($langcode);
// Needed to re-run language negotiation.
$this->languageManager
->reset();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
LanguageAwareSendMailQueueWorker:: |
protected | property | The configurable language manager. | |
LanguageAwareSendMailQueueWorker:: |
protected | property | The queue mail language negotiator. | |
LanguageAwareSendMailQueueWorker:: |
public static | function |
Creates an instance of the plugin. Overrides SendMailQueueWorker:: |
|
LanguageAwareSendMailQueueWorker:: |
protected | function |
Restores back the negotiated language. Overrides SendMailQueueWorker:: |
|
LanguageAwareSendMailQueueWorker:: |
protected | function |
Sets language from the message. Overrides SendMailQueueWorker:: |
|
LanguageAwareSendMailQueueWorker:: |
protected | function | Sets the queue mail negotiator language. | |
LanguageAwareSendMailQueueWorker:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides SendMailQueueWorker:: |
|
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SendMailQueueWorker:: |
protected | property | Active theme. | |
SendMailQueueWorker:: |
protected | property | Queue mail configuration. | |
SendMailQueueWorker:: |
protected | property | Logger. | |
SendMailQueueWorker:: |
protected | property | Mail manager. | |
SendMailQueueWorker:: |
protected | property | The module handler to invoke the alter hook. | |
SendMailQueueWorker:: |
protected | property | Queue for sending mails. | |
SendMailQueueWorker:: |
protected | property | Theme initialization. | |
SendMailQueueWorker:: |
protected | property | Theme manager. | |
SendMailQueueWorker:: |
protected | function | Checks if message has been generated using another theme. | |
SendMailQueueWorker:: |
public | function |
Works on a single queue item. Overrides QueueWorkerInterface:: |
|
SendMailQueueWorker:: |
protected | function | Retry limit handler. | |
SendMailQueueWorker:: |
protected | function | Restore back theme that is used by default. | |
SendMailQueueWorker:: |
protected | function | Set theme from the theme. | |
SendMailQueueWorker:: |
protected | function | Wait between items processing. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |