// Add the module that is providing the database driver to the list of
// modules that can not be uninstalled in the core.extension configuration.
if(file_exists($config_sync_directory . '/core.extension.yml')){ $core_extension = Yaml::decode(file_get_contents($config_sync_directory . '/core.extension.yml')); $module = Database::getConnection()->getProvider(); if($module !== 'core'){ $core_extension['module'][$module] = 0; $core_extension['module'] = module_config_sort($core_extension['module']); file_put_contents($config_sync_directory . '/core.extension.yml', Yaml::encode($core_extension)); } } }
/**
* Gets the filepath to the configuration tarball.
*
* The tarball will be extracted to the install profile's config/sync
* directory for testing.
*
* @return string
* The filepath to the configuration tarball.
*/
// in hook_install() are not reflected in $extension_config.
$extension_config = \Drupal::configFactory()->getEditable('core.extension');
// Check the validity of the default configuration. This will throw
// exceptions if the configuration is not valid.
$config_installer->checkConfigurationToInstall('module', $module);
// Save this data without checking schema. This is a performance
// improvement for module installation.
$extension_config ->set("module.$module", 0) ->set('module', module_config_sort($extension_config->get('module'))) ->save(TRUE);
// Prepare the new module list, sorted by weight, including filenames.
// This list is used for both the ModuleHandler and DrupalKernel. It
// needs to be kept in sync between both. A DrupalKernel reboot or
// rebuild will automatically re-instantiate a new ModuleHandler that
// uses the new module list of the kernel. However, DrupalKernel does
// not cause any modules to be loaded.
// Furthermore, the currently active (fixed) module list can be
// different from the configured list of enabled modules. For all active
// modules not contained in the configured enabled modules, we assume a
$modules = $extension['module']; foreach($this->getExcludedModules()as$module){ if(array_key_exists($module, $existing['module'])){ // Set the modules weight from the active store.
$modules[$module] = $existing['module'][$module]; } }
// Sort the extensions.
$extension['module'] = module_config_sort($modules); // Set the modified extension.
$storage->write('core.extension', $extension); }
/**
* Transform the storage which is used to export the configuration.
*
* Make sure excluded modules are not exported by removing all the config
* which depends on them from the storage that is exported.
*
* @param \Drupal\Core\Config\StorageTransformEvent $event
* The transformation event.
*/
/**
* Tests that a module can add services that depend on new modules.
*/ publicfunctiontestUpdateNewDependency(){ // The new_dependency_test before the update is just an empty info.yml file.
// The code of the new_dependency_test module is after the update and
// contains the dependency on the new_dependency_test_with_service module.
$extension_config = $this->container->get('config.factory')->getEditable('core.extension'); $extension_config ->set('module.new_dependency_test', 0) ->set('module', module_config_sort($extension_config->get('module'))) ->save(TRUE); \Drupal::service('update.update_hook_registry')->setInstalledVersion('new_dependency_test', \Drupal::CORE_MINIMUM_SCHEMA_VERSION);
// Rebuild the container and test that the service with the optional unmet
// dependency is still available while the ones that fail are not.
try{ $this->rebuildContainer(); $this->fail('The container has services with unmet dependencies and should have failed to rebuild.'); } catch(ServiceNotFoundException $exception){ $this->assertStringContainsString('The service "new_dependency_test.dependent" has a dependency on a non-existent service "new_dependency_test_with_service.service".', $exception->getMessage()); }
// Enable the Automated Cron and Ban modules during import. The Ban
// module is used because it creates a table during the install.
// The Automated Cron module is used because it creates a single simple
// configuration file during the install.
$core_extension = $this->config('core.extension')->get(); $core_extension['module']['automated_cron'] = 0; $core_extension['module']['ban'] = 0; $core_extension['module'] = module_config_sort($core_extension['module']); $core_extension['theme']['olivero'] = 0; $sync->write('core.extension', $core_extension); // Olivero ships with configuration.
$sync->write('olivero.settings', Yaml::decode(file_get_contents('core/themes/olivero/config/install/olivero.settings.yml')));
// Use the install storage so that we can read configuration from modules
// and themes that are not installed.
$install_storage = newInstallStorage();
// Set the Olivero theme as default.
$system_theme = $this->config('system.theme')->get();