protected function Immediately::sendEmail in Open Social 10.3.x
Same name and namespace in other branches
- 8.9 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.2 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.3 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.4 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.5 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.6 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.7 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 8.8 modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 10.0.x modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 10.1.x modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
- 10.2.x modules/custom/activity_send/modules/activity_send_email/src/Plugin/EmailFrequency/Immediately.php \Drupal\activity_send_email\Plugin\EmailFrequency\Immediately::sendEmail()
Send an email with a single notification.
Parameters
string $body_text: The text to send to the target user.
string $langcode: The langcode of the target user.
\Drupal\user\Entity\User $target: The target account to send the email to.
1 call to Immediately::sendEmail()
- Immediately::processItem in modules/
custom/ activity_send/ modules/ activity_send_email/ src/ Plugin/ EmailFrequency/ Immediately.php - Processes an activity item.
File
- modules/
custom/ activity_send/ modules/ activity_send_email/ src/ Plugin/ EmailFrequency/ Immediately.php, line 59
Class
- Immediately
- Define a concrete class for immediate emails.
Namespace
Drupal\activity_send_email\Plugin\EmailFrequencyCode
protected function sendEmail(string $body_text, string $langcode, User $target) {
// Translating frequency instance in the language of the user.
// @codingStandardsIgnoreStart
$frequency_translated = t($this
->getName()
->getUntranslatedString(), [], [
'langcode' => $langcode,
]);
// @codingStandardsIgnoreEnd
// Construct the render array.
$notification = [
'#theme' => 'directmail',
'#notification' => $body_text,
'#notification_settings' => t('Based on your @settings, the notification above is sent to you <strong>:frequency</strong>', [
'@settings' => Link::fromTextAndUrl(t('email notification settings', [], [
'langcode' => $langcode,
]), Url::fromRoute('activity_send_email.user_edit_page')
->setAbsolute())
->toString(),
':frequency' => $frequency_translated,
], [
'langcode' => $langcode,
]),
];
$params['body'] = \Drupal::service('renderer')
->renderRoot($notification);
// Send the email.
$mail_manager = \Drupal::service('plugin.manager.mail');
$mail_manager
->mail('activity_send_email', 'activity_send_email', $target
->getEmail(), $langcode, $params, NULL, TRUE);
}