From 81ef7a6eb3e4d499a661cf831e71dd359a14730c Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Thu, 26 Apr 2018 13:54:48 +0100 Subject: [PATCH] Issue #2776605 by chr.fritsch, phenaproxima, dawehner: Make it possible to specify a destination after the installation for distributions --- core/includes/install.core.inc | 6 +++++- core/includes/install.inc | 2 ++ .../FunctionalTests/Installer/DistributionProfileTest.php | 4 +++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc index c27f75e1782e..d71e0c86a9fb 100644 --- a/core/includes/install.core.inc +++ b/core/includes/install.core.inc @@ -160,7 +160,11 @@ function install_drupal($class_loader, $settings = []) { } elseif ($state['installation_finished']) { // Redirect to the newly installed site. - install_goto(''); + $finish_url = ''; + if (isset($install_state['profile_info']['distribution']['install']['finish_url'])) { + $finish_url = $install_state['profile_info']['distribution']['install']['finish_url']; + } + install_goto($finish_url); } } } diff --git a/core/includes/install.inc b/core/includes/install.inc index 399476f102f2..2a726bdcde7f 100644 --- a/core/includes/install.inc +++ b/core/includes/install.inc @@ -1056,6 +1056,8 @@ function drupal_check_module($module) { * - install: Optional parameters to override the installer: * - theme: The machine name of a theme to use in the installer instead of * Drupal's default installer theme. + * - finish_url: A destination to visit after the installation of the + * distribution is finished * * Note that this function does an expensive file system scan to get info file * information for dependencies. If you only need information from the info diff --git a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php index 7306e975534a..1e4392981f92 100644 --- a/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php +++ b/core/tests/Drupal/FunctionalTests/Installer/DistributionProfileTest.php @@ -29,6 +29,7 @@ protected function prepareEnvironment() { 'name' => 'My Distribution', 'install' => [ 'theme' => 'bartik', + 'finish_url' => '/myrootuser', ], ], ]; @@ -36,6 +37,7 @@ protected function prepareEnvironment() { $path = $this->siteDirectory . '/profiles/mydistro'; mkdir($path, 0777, TRUE); file_put_contents("$path/mydistro.info.yml", Yaml::encode($this->info)); + file_put_contents("$path/mydistro.install", "<?php function mydistro_install() {\Drupal::service('path.alias_storage')->save('/user/1', '/myrootuser');}"); } /** @@ -65,7 +67,7 @@ protected function setUpProfile() { * Confirms that the installation succeeded. */ public function testInstalled() { - $this->assertUrl('user/1'); + $this->assertUrl('myrootuser'); $this->assertResponse(200); // Confirm that we are logged-in after installation. $this->assertText($this->rootUser->getUsername()); -- GitLab