function sitemap_update_8200 in Sitemap 2.0.x
Same name and namespace in other branches
- 8.2 sitemap.install \sitemap_update_8200()
Update configuration for 2.x.
File
- ./
sitemap.install, line 39 - Installation functions for Sitemap module.
Code
function sitemap_update_8200(&$sandbox) {
$config_factory = \Drupal::configFactory();
$config = $config_factory
->getEditable('sitemap.settings');
// Update the config key for the CSS option.
$config
->set('include_css', $config
->get('css'));
$config
->clear('css');
// Remove the config for the RSS position option.
$show_rss = (bool) $config
->get('show_rss_links');
$config
->clear('show_rss_links');
$plugins = [];
$show_titles = $config
->get('show_titles');
$order = $config
->get('order');
$config
->clear('show_titles');
$config
->clear('order');
// Update to the frontpage plugin.
$plugins['frontpage'] = [
'enabled' => (bool) $config
->get('show_front'),
'weight' => isset($order['front']) ? $order['front'] : 0,
'settings' => [
'title' => $show_titles ? 'Front page' : '',
'rss' => $config
->get('rss_front') && $show_rss ? '/' . $config
->get('rss_front') : '',
],
];
$config
->clear('show_front');
$config
->clear('rss_front');
// Update to the book plugin.
if ($books = $config
->get('show_books')) {
foreach ($books as $bid => $enabled) {
$plugins['book:' . $bid] = [
'enabled' => (bool) $enabled,
'weight' => isset($order['books_' . $bid]) ? $order['books_' . $bid] : 0,
'settings' => [
'title' => sitemap_book_title_update($bid, $show_titles),
'show_expanded' => $config
->get('books_expanded'),
],
];
}
}
$config
->clear('show_books');
$config
->clear('books_expanded');
// Update to the menu plugin.
if ($menus = $config
->get('show_menus')) {
foreach ($menus as $menu_id => $enabled) {
$plugins['menu:' . $menu_id] = [
'enabled' => (bool) $enabled,
'weight' => isset($order['menus_' . $menu_id]) ? $order['menus_' . $menu_id] : 0,
'settings' => [
'title' => sitemap_menu_title_update($menu_id, $show_titles),
'show_disabled' => $config
->get('show_menus_hidden'),
],
];
}
}
$config
->clear('show_menus');
$config
->clear('show_menus_hidden');
// Update to the vocabulary plugin.
if ($vocabs = $config
->get('show_vocabularies')) {
if (\Drupal::service('module_handler')
->moduleExists('forum')) {
$forumVid = \Drupal::config('forum.settings')
->get('vocabulary');
}
foreach ($vocabs as $vid => $enabled) {
$plugins['vocabulary:' . $vid] = [
'enabled' => (bool) $enabled,
'weight' => isset($order['vocabularies_' . $vid]) ? $order['vocabularies_' . $vid] : 0,
'settings' => [
'title' => $show_titles ? sitemap_vocab_title_update($vid) : '',
'show_description' => $config
->get('show_description'),
'show_count' => $config
->get('show_count'),
'term_depth' => sitemap_vocab_depth_update($config
->get('vocabulary_depth')),
'term_count_threshold' => isset($formVid) && $forumVid == $vid ? sitemap_vocab_threshold_update($config
->get('forum_threshold')) : sitemap_vocab_threshold_update($config
->get('term_threshold')),
'customize_link' => $config
->get('vocabulary_show_links'),
'term_link' => Vocabulary::DEFAULT_TERM_LINK,
'always_link' => $config
->get('vocabulary_show_links'),
'enable_rss' => (bool) sitemap_vocab_depth_update($config
->get('rss_taxonomy')),
'rss_link' => Vocabulary::DEFAULT_TERM_RSS_LINK,
'rss_depth' => sitemap_vocab_depth_update($config
->get('rss_taxonomy')),
],
];
}
}
$config
->clear('show_vocabularies');
$config
->clear('show_description');
$config
->clear('show_count');
$config
->clear('vocabulary_depth');
$config
->clear('vocabulary_show_links');
$config
->clear('term_threshold');
$config
->clear('forum_threshold');
$config
->clear('rss_taxonomy');
$config
->set('plugins', $plugins);
$config
->save(TRUE);
}