function mandrill_template_map_load_by_mailsystem in Mandrill 7
Same name and namespace in other branches
- 8 modules/mandrill_template/mandrill_template.module \mandrill_template_map_load_by_mailsystem()
- 7.2 modules/mandrill_template/mandrill_template.module \mandrill_template_map_load_by_mailsystem()
Tells you which template_map is configured for a mailsystem key, if any.
Will search for a default-system mapping if none is availble for a given key.
Parameters
string $mailsystem: Mail key to search for a template mapping.
Return value
entity Mandrill template map.
1 call to mandrill_template_map_load_by_mailsystem()
- mandrill_template_mandrill_mail_alter in modules/
mandrill_template/ mandrill_template.module - Implements hook_mandrill_mail_alter().
File
- modules/
mandrill_template/ mandrill_template.module, line 90 - Enables Drupal to send email using Mandrill's template system.
Code
function mandrill_template_map_load_by_mailsystem($mailsystem) {
// Append the default-system condition as a fallback.
$params = array(
$mailsystem,
'default-system',
);
$query = new EntityFieldQuery();
$query_result = $query
->entityCondition('entity_type', 'mandrill_template_map')
->propertyCondition('mailsystem_key', $params, 'IN')
->execute();
if (!empty($query_result['mandrill_template_map'])) {
$template_maps = entity_load('mandrill_template_map', array_keys($query_result['mandrill_template_map']));
if (count($template_maps) > 1) {
foreach ($template_maps as $template_map) {
if ($template_map->mailsystem_key == $mailsystem) {
return $template_map;
}
}
}
else {
return reset($template_maps);
}
}
return NULL;
}