function social_swiftmail_preprocess_swiftmailer in Open Social 8
Same name and namespace in other branches
- 8.9 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.2 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.3 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.4 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.5 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.6 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.7 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 8.8 modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 10.3.x modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 10.0.x modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 10.1.x modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
- 10.2.x modules/social_features/social_swiftmail/social_swiftmail.module \social_swiftmail_preprocess_swiftmailer()
Preprocess swift template.
File
- modules/
social_features/ social_swiftmail/ social_swiftmail.module, line 14 - Module file for Social Swiftmailer.
Code
function social_swiftmail_preprocess_swiftmailer(array &$variables) {
// Load default theme (not active).
$theme_id = \Drupal::config('system.theme')
->get('default');
// Need to check this, since otherwise site-install will fail.
if (\Drupal::service('module_handler')
->moduleExists('color')) {
// Load the colors.
$colors = color_get_palette($theme_id);
}
// Set variables from theme.
$logo = social_swiftmail_get_logo($theme_id);
$primary = $colors['brand-primary'];
$secondary = $colors['brand-secondary'];
$accent = $colors['brand-accent'];
$link = $colors['brand-link'];
$border_radius = Xss::filter(theme_get_setting('border_radius', $theme_id));
// Add variables to send to the html template.
$variables['logo'] = $logo;
$variables['primary'] = $primary;
$variables['secondary'] = $secondary;
$variables['accent'] = $accent;
$variables['link'] = $link;
$variables['border_radius'] = $border_radius;
// Try to add a heading message.
if ($user = user_load_by_mail($variables['message']['to'])) {
$message = $variables['message'];
$options = [
'langcode' => $message['langcode'],
];
$replace = [
'%display_name' => $user
->getDisplayName(),
];
$variables['heading'] = t('Hi %display_name', $replace, $options);
}
}