function language_modules_installed

Same name in other branches
  1. 9 core/modules/language/language.module \language_modules_installed()
  2. 8.9.x core/modules/language/language.module \language_modules_installed()

Implements hook_modules_installed().

1 call to language_modules_installed()
language_modules_uninstalled in core/modules/language/language.module
Implements hook_modules_uninstalled().

File

core/modules/language/language.module, line 295

Code

function language_modules_installed($modules, $is_syncing) {
    if ($is_syncing) {
        return;
    }
    if (!in_array('language', $modules)) {
        if (InstallerKernel::installationAttempted() && ($profile = \Drupal::installProfile())) {
            // If the install profile provides its own language.types configuration do
            // not overwrite it.
            $profile_directory = \Drupal::service('extension.list.profile')->getPath($profile);
            $profile_storages = [
                new FileStorage($profile_directory . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY),
                new FileStorage($profile_directory . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY),
            ];
            foreach ($profile_storages as $storage) {
                if ($storage->exists('language.types')) {
                    return;
                }
            }
        }
        // Since newly (un)installed modules may change the default settings for
        // non-locked language types (e.g. content language), we need to resave the
        // language type configuration.
        
        /** @var \Drupal\language\LanguageNegotiatorInterface $negotiator */
        $negotiator = \Drupal::service('language_negotiator');
        $configurable = \Drupal::config('language.types')->get('configurable');
        $negotiator->updateConfiguration($configurable);
        $negotiator->purgeConfiguration();
    }
    else {
        // In language_entity_base_field_info_alter() we are altering view/form
        // display definitions to make language fields display configurable. Since
        // this is not a hard dependency, and thus is not detected by the config
        // system, we have to clean up the related values manually.
        foreach ([
            'entity_view_display',
            'entity_form_display',
        ] as $key) {
            $displays = \Drupal::entityTypeManager()->getStorage($key)
                ->loadMultiple();
            
            /** @var \Drupal\Core\Entity\Display\EntityDisplayInterface $display */
            foreach ($displays as $display) {
                $display->save();
            }
        }
    }
}

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