function MailEntity::getSubject in Simplenews 8
Same name and namespace in other branches
- 8.2 src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::getSubject()
- 3.x src/Mail/MailEntity.php \Drupal\simplenews\Mail\MailEntity::getSubject()
Returns the mail subject.
Return value
string The mail subject.
Overrides MailInterface::getSubject
File
- src/
Mail/ MailEntity.php, line 237
Class
- MailEntity
- Default mail class for entities.
Namespace
Drupal\simplenews\MailCode
function getSubject() {
// Build email subject and perform some sanitizing.
// Use the requested language if enabled.
$langcode = $this
->getLanguage();
$subject = \Drupal::token()
->replace($this
->getNewsletter()->subject, $this
->getTokenContext(), array(
'sanitize' => FALSE,
'langcode' => $langcode,
));
// Line breaks are removed from the email subject to prevent injection of
// malicious data into the email header.
$subject = str_replace(array(
"\r",
"\n",
), '', $subject);
return $subject;
}