function system_update_8006 in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/system.install \system_update_8006()
Place branding blocks in every theme.
File
- core/
modules/ system/ system.install, line 1500 - Install, update and uninstall functions for the system module.
Code
function system_update_8006() {
// When block module is not installed, there is nothing that could be done
// except showing a warning.
if (!\Drupal::moduleHandler()
->moduleExists('block')) {
return t('Block module is not enabled so site branding elements, which have been converted to a block, are not visible anymore.');
}
/** @var \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler */
$theme_handler = \Drupal::service('theme_handler');
$custom_themes_installed = FALSE;
$message = NULL;
$langcode = \Drupal::service('language_manager')
->getCurrentLanguage()
->getId();
$site_branding_default_settings = [
'plugin' => 'system_branding_block',
'region' => 'content',
'settings.label' => 'Site branding',
'settings.label_display' => 0,
'visibility' => [],
'weight' => 0,
'langcode' => $langcode,
];
foreach ($theme_handler
->listInfo() as $theme) {
$theme_name = $theme
->getName();
switch ($theme_name) {
case 'bartik':
$name = 'block.block.bartik_branding';
$values = [
'id' => 'bartik_branding',
'region' => 'header',
] + $site_branding_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
case 'stark':
$name = 'block.block.stark_branding';
$values = [
'id' => 'stark_branding',
'region' => 'header',
] + $site_branding_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
case 'seven':
case 'classy':
case 'stable':
// Don't place any blocks or trigger custom themes installed warning.
break;
default:
$custom_themes_installed = TRUE;
$name = sprintf('block.block.%s_branding', $theme_name);
$values = [
'id' => sprintf('%s_branding', $theme_name),
'region' => 'content',
'weight' => '-50',
] + $site_branding_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
}
}
if ($custom_themes_installed) {
$message = t('Because your site has custom theme(s) installed, we had to set the branding block into the content region. Please manually review the block configuration and remove the site name, slogan, and logo variables from your templates.');
}
return $message;
}