function social_font_post_update_montserrat_fallback in Open Social 8.9
Same name and namespace in other branches
- 8.5 modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 8.6 modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 8.7 modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 8.8 modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 10.3.x modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 10.0.x modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 10.1.x modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
- 10.2.x modules/custom/social_font/social_font.post_update.php \social_font_post_update_montserrat_fallback()
Set font-fallback for Montserrat font to sans-serif.
File
- modules/
custom/ social_font/ social_font.post_update.php, line 13 - Post-update hooks for the Social Font module.
Code
function social_font_post_update_montserrat_fallback() {
// We assume that the number of fonts installed on a site will never be
// massive but we can't be sure that Montserrat has id 0 or 1.
$fonts = Font::loadMultiple();
/** @var Drupal\social_font\Entity\Font $font */
foreach ($fonts as $font) {
if ($font
->getName() === "Montserrat") {
// Set the fallback to use sans-serif.
$font
->set('field_fallback', "1");
$font
->save();
}
}
}