Commit aeae01b3 authored by catch's avatar catch
Browse files

Issue #3087130 by alexpott, aleevas, rensingh99, andypost, chr.fritsch,...

Issue #3087130 by alexpott, aleevas, rensingh99, andypost, chr.fritsch, DanielVeza: Profile configuration should be able to depend on optional configuration provided by modules
parent 5b446846
......@@ -1638,7 +1638,6 @@ function install_profile_themes(&$install_state) {
* An array of information about the current installation state.
*/
function install_install_profile(&$install_state) {
\Drupal::service('module_installer')->install([$install_state['parameters']['profile']], FALSE);
// Install all available optional config. During installation the module order
// is determined by dependencies. If there are no dependencies between modules
// then the order in which they are installed is dependent on random factors
......@@ -1648,6 +1647,8 @@ function install_install_profile(&$install_state) {
// any disparities that this creates.
\Drupal::service('config.installer')->installOptionalConfig();
\Drupal::service('module_installer')->install([$install_state['parameters']['profile']], FALSE);
// Ensure that the install profile's theme is used.
// @see _drupal_maintenance_theme()
\Drupal::theme()->resetActiveTheme();
......
......@@ -140,9 +140,11 @@ public function installDefaultConfig($type, $name) {
}
// During a drupal installation optional configuration is installed at the
// end of the installation process.
// end of the installation process. Once the install profile is installed
// optional configuration should be installed as usual.
// @see install_install_profile()
if (!$this->isSyncing() && !InstallerKernel::installationAttempted()) {
$profile_installed = in_array($this->drupalGetProfile(), $this->getEnabledExtensions(), TRUE);
if (!$this->isSyncing() && (!InstallerKernel::installationAttempted() || $profile_installed)) {
$optional_install_path = $extension_path . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY;
if (is_dir($optional_install_path)) {
// Install any optional config the module provides.
......
......@@ -91,6 +91,10 @@ public function testInstallProfileConfigOverwrite() {
$tour = Tour::load('language-add');
$this->assertCount(3, $tour->getTips(), 'Optional configuration that is not overridden is not affected.');
// Ensure the optional configuration is installed. Note that the overridden
// language tour has a dependency on this tour so it has to exist.
$this->assertInstanceOf(Tour::class, Tour::load('testing_config_overrides_module'));
// Ensure that optional configuration from a profile is created if
// dependencies are met.
$this->assertEquals('Config override test', Tour::load('testing_config_overrides')->label());
......
......@@ -8,10 +8,12 @@
use Drupal\demo_umami_content\InstallHelper;
/**
* Implements hook_install().
* Implements hook_module_preinstall().
*/
function demo_umami_content_install($is_syncing) {
if (!$is_syncing) {
function demo_umami_content_module_preinstall($module) {
if ($module === 'demo_umami_content' && !\Drupal::service('config.installer')->isSyncing()) {
// Run before importing config so blocks are created with the correct
// dependencies.
\Drupal::classResolver(InstallHelper::class)->importContent();
}
}
......
id: language
# The enforced dependency ensures that profile configuration in config/install
# can depend on optional configuration of modules and themes it installs.
dependencies:
enforced:
config:
- tour.tour.testing_config_overrides_module
module:
- language
module: language
label: Language
langcode: en
......
id: testing_config_overrides
module: testing_config_overrides
# This depends on configuration in the install's config/install directory so we
# can test that this configuration is installed.
dependencies:
enforced:
config:
- tour.tour.language
module:
- testing_config_overrides
label: Config override test
langcode: en
routes:
......
id: testing_config_overrides_module
module: testing_config_overrides_module
label: Config override test
langcode: en
routes:
- route_name: system.admin
tips:
overview:
id: block-seven-content
plugin: text
label: Test
body: '<p>This is a test.</p>'
weight: 1
name: 'Testing config dependencies and optional configuration'
type: module
package: Testing
version: VERSION
......@@ -9,4 +9,5 @@ hidden: true
install:
- action
- language
- testing_config_overrides_module
- tour
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment