private function SWIFTMailSystem::getApplicableFormat in Swift Mailer 7
Returns the applicable format.
Parameters
array $message: The message for which the applicable format is to be determined.
Return value
string A string being the applicable format.
2 calls to SWIFTMailSystem::getApplicableFormat()
- SWIFTMailSystem::format in includes/
classes/ SWIFTMailSystem.inc - Formats a message composed by drupal_mail().
- SWIFTMailSystem::mail in includes/
classes/ SWIFTMailSystem.inc - Sends a message composed by drupal_mail().
File
- includes/
classes/ SWIFTMailSystem.inc, line 479 - The implementation of MailSystemInterface which delegates handling of e-mails to the Swift Mailer library.
Class
- SWIFTMailSystem
- @file The implementation of MailSystemInterface which delegates handling of e-mails to the Swift Mailer library.
Code
private function getApplicableFormat($message) {
// Get the configured default format.
$default_format = variable_get('swiftmailer_format', SWIFTMAILER_VARIABLE_FORMAT_DEFAULT);
// Get whether the provided format is to be respected.
$respect_format = variable_get('swiftmailer_respect_format', SWIFTMAILER_VARIABLE_RESPECT_FORMAT_DEFAULT);
// Check if a format has been provided particularly for this message. If
// that is the case, then apply that format instead of the default format.
$applicable_format = !empty($message['params']['format']) ? $message['params']['format'] : $default_format;
// Check if the provided format is to be respected, and if a format has been
// set through the header "Content-Type". If that is the case, the apply the
// format provided. This will override any format which may have been set
// through $message['params']['format'].
if ($respect_format && !empty($message['headers']['Content-Type'])) {
$format = $message['headers']['Content-Type'];
$format = preg_match('/.*\\;/U', $format, $matches);
if ($format > 0) {
$applicable_format = trim(substr($matches[0], 0, -1));
}
else {
$applicable_format = $default_format;
}
}
return $applicable_format;
}