You are here

function menu_breadcrumb_update_8101 in Menu Breadcrumb 8

Same name and namespace in other branches
  1. 2.0.x menu_breadcrumb.install \menu_breadcrumb_update_8101()

Set new front_title config key from home_as_site_name.

File

./menu_breadcrumb.install, line 11
Install, update and uninstall functions for the menu breadcrumb module.

Code

function menu_breadcrumb_update_8101() {
  $config = \Drupal::configFactory()
    ->getEditable('menu_breadcrumb.settings');
  $home_as_site_name = $config
    ->get('home_as_site_name');

  // We suppose that if home_as_site_name is null it is because the settings
  // form had been resaved or a custom update path had been done on the website.
  if (!is_null($home_as_site_name)) {

    // If the front_title key has already been set, do nothing.
    if (is_null($config
      ->get('front_title'))) {
      if ($home_as_site_name == FALSE) {
        $config
          ->set('front_title', 1);
      }
      else {
        $config
          ->set('front_title', 0);
      }
    }

    // Remove the previous key.
    $config
      ->clear('home_as_site_name');
    $config
      ->save(TRUE);
  }
}