function system_update_8010 in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/system.install \system_update_8010()
Place page title blocks in every theme.
File
- core/
modules/ system/ system.install, line 1708 - Install, update and uninstall functions for the system module.
Code
function system_update_8010() {
// 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. The page title has been converted to a block, but default page title markup will still display at the top of the main content area.');
}
/** @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();
$page_title_default_settings = [
'plugin' => 'page_title_block',
'region' => 'content',
'settings.label' => 'Page title',
'settings.label_display' => 0,
'visibility' => [],
'weight' => -50,
'langcode' => $langcode,
];
foreach ($theme_handler
->listInfo() as $theme) {
$theme_name = $theme
->getName();
switch ($theme_name) {
case 'bartik':
$name = 'block.block.bartik_page_title';
$values = [
'id' => 'bartik_page_title',
] + $page_title_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
case 'stark':
$name = 'block.block.stark_page_title';
$values = [
'id' => 'stark_page_title',
'region' => 'content',
] + $page_title_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
case 'seven':
$name = 'block.block.seven_page_title';
$values = [
'id' => 'seven_page_title',
'region' => 'header',
] + $page_title_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
case 'classy':
$name = 'block.block.classy_page_title';
$values = [
'id' => 'classy_page_title',
'region' => 'content',
] + $page_title_default_settings;
_system_update_create_block($name, $theme_name, $values);
break;
default:
$custom_themes_installed = TRUE;
$name = sprintf('block.block.%s_page_title', $theme_name);
$values = [
'id' => sprintf('%s_page_title', $theme_name),
'region' => 'content',
'weight' => '-50',
] + $page_title_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 have placed the page title block in the content region. Please manually review the block configuration and remove the page title variables from your page templates.');
}
return $message;
}