function mandrill_template_map_load_by_mailsystem in Mandrill 7.2
Same name and namespace in other branches
- 8 modules/mandrill_template/mandrill_template.module \mandrill_template_map_load_by_mailsystem()
- 7 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($module_key, $module) {
// Append the default-system condition as a fallback.
$params = array(
$module_key,
$module,
'default-system',
);
$query = new EntityFieldQuery();
$query_result = $query
->entityCondition('entity_type', 'mandrill_template_map')
->propertyCondition('mailsystem_key', $params, 'IN')
->execute();
$module_match = FALSE;
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) {
switch ($template_map->mailsystem_key) {
case $module_key:
return $template_map;
case $module:
$module_match = $template_map;
break;
}
}
}
return $module_match ? $module_match : reset($template_maps);
}
return NULL;
}