function shortcut_uninstall

Same name and namespace in other branches
  1. 11.x core/modules/shortcut/shortcut.install \shortcut_uninstall()
  2. 10 core/modules/shortcut/shortcut.install \shortcut_uninstall()
  3. 9 core/modules/shortcut/shortcut.install \shortcut_uninstall()
  4. 8.9.x core/modules/shortcut/shortcut.install \shortcut_uninstall()
  5. 7.x modules/shortcut/shortcut.install \shortcut_uninstall()

Implements hook_uninstall().

File

core/modules/shortcut/shortcut.install, line 106

Code

function shortcut_uninstall() : void {
  // Theme settings are not configuration entities and cannot depend on modules
  // so to unset a module-specific setting, we need to unset it with logic.
  if (\Drupal::service('theme_handler')->themeExists('claro')) {
    \Drupal::configFactory()->getEditable("claro.settings")
      ->clear('third_party_settings.shortcut')
      ->save();
  }
  if (\Drupal::service('theme_handler')->themeExists('olivero')) {
    \Drupal::configFactory()->getEditable("olivero.settings")
      ->clear('third_party_settings.shortcut')
      ->save();
  }
  // Remove the navigation_shortcuts block from the navigation layout.
  // @todo Fix Navigation so it does not store dependencies in config.
  //   https://www.drupal.org/project/drupal/issues/3587499
  if (\Drupal::moduleHandler()->moduleExists('navigation')) {
    /** @var \Drupal\layout_builder\SectionStorage\SectionStorageManagerInterface $section_storage_manager */
    $section_storage_manager = \Drupal::service('plugin.manager.layout_builder.section_storage');
    $navigation_storage = $section_storage_manager->load('navigation', [
      'navigation' => new Context(new ContextDefinition('string'), 'navigation'),
    ]);
    if ($navigation_storage) {
      foreach ($navigation_storage->getSections() as $section) {
        foreach ($section->getComponents() as $uuid => $component) {
          if ($component->getPluginId() === 'navigation_shortcuts') {
            $section->removeComponent($uuid);
          }
        }
        $navigation_storage->save();
      }
    }
  }
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.