private function PrivateMessageMailer::shouldSend in Private Message 8
Determines if the message should be sent.
Checks individual user preferences as well as system defaults.
Parameters
\Drupal\Core\Session\AccountInterface $recipient: The potential recipient.
Return value
bool A boolean indicating whether or not the message should be sent.
1 call to PrivateMessageMailer::shouldSend()
- PrivateMessageMailer::send in src/
Service/ PrivateMessageMailer.php - Send a private message notification email.
File
- src/
Service/ PrivateMessageMailer.php, line 115
Class
- PrivateMessageMailer
- A service class for sending notification emails for private messages.
Namespace
Drupal\private_message\ServiceCode
private function shouldSend(AccountInterface $recipient) {
// If the recipient email address is not populated, return FALSE.
if (!$recipient
->getEmail()) {
return FALSE;
}
// If the user data value is set, return it as a boolean.
if (($value = $this->userData
->get('private_message', $recipient
->id(), 'email_notification')) !== NULL) {
return (bool) $value;
}
return $this->config
->get('enable_email_notifications') && $this->config
->get('send_by_default');
}