You are here

function sitemap_menu_title_update in Sitemap 2.0.x

Same name and namespace in other branches
  1. 8.2 sitemap.install \sitemap_menu_title_update()

Helper function to get a menu title from 1.x menu settings.

Parameters

string $menu_id:

bool $show_title:

Return value

string

1 call to sitemap_menu_title_update()
sitemap_update_8200 in ./sitemap.install
Update configuration for 2.x.

File

./sitemap.install, line 168
Installation functions for Sitemap module.

Code

function sitemap_menu_title_update($menu_id, $show_title) {
  $config_factory = \Drupal::configFactory();
  $config = $config_factory
    ->getEditable('system.menu.' . $menu_id);
  $title = '';
  if ($show_title) {
    if ($thirdParty = $config
      ->get('third_party_settings')) {
      if (isset($thirdParty['sitemap']) && ($setting = $thirdParty['sitemap'])) {
        if (isset($setting['sitemap_display_name'])) {
          $title = $setting['sitemap_display_name'];
        }
      }
    }
    if (empty($title)) {
      $title = $config
        ->get('label');
    }
  }
  $config
    ->clear('third_party_settings.sitemap');
  $config
    ->save();
  return $title;
}