diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php index 9b6a889..8ff1ee5 100644 --- a/core/lib/Drupal/Core/DrupalKernel.php +++ b/core/lib/Drupal/Core/DrupalKernel.php @@ -1526,9 +1526,30 @@ protected function getInstallProfile() { } /** - * {@inheritdoc} - */ - public function getDistribution() { + * Get the name of any discovered profile that is a distribution. + * + * Scans the filesystem looking for all installation profiles. + * Returns the one that has a 'distribution' entry in its info.yml + * file. If multiple profiles are distributions, an exception will + * be thrown. + * + * This is used in two places: + * 1) During installation, if there is a single distribution, then + * the installer will not write the installation profile name + * to settings.php. + * 2) Whenever DrupalKernel::getInstallProfile() is called, if there + * is no installation profile name noted in settings.php, then + * it will call this function to determine the distribution + * to use. + * + * @return string|FALSE + * The machine name of any discovered distribution. FALSE if there are no + * distributions. + * + * @throws \Drupal\Core\Installer\Exception\TooManyDistributionsException + * Thrown when a site has more than one distribution installation profile. + */ + protected function getDistribution() { $listing = new ExtensionDiscovery($this->root); $listing->setProfileDirectories(array()); $info_parser = new InfoParser(); diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php index ac21dd2..99a7420 100644 --- a/core/lib/Drupal/Core/DrupalKernelInterface.php +++ b/core/lib/Drupal/Core/DrupalKernelInterface.php @@ -139,19 +139,4 @@ public function preHandle(Request $request); * Helper method that loads legacy Drupal include files. */ public function loadLegacyIncludes(); - - /** - * Get the name of any discovered profile that is a distribution. - * - * If multiple profiles are distributions an exception will be thrown. - * - * @return string|FALSE - * The machine name of any discovered distribution. FALSE if there are no - * distributions. - * - * @throws \Drupal\Core\Installer\Exception\TooManyDistributionsException - * Thrown when a site has more than one distribution installation profile. - */ - public function getDistribution(); - } diff --git a/core/lib/Drupal/Core/Installer/InstallerKernel.php b/core/lib/Drupal/Core/Installer/InstallerKernel.php index adeb5c5..c149985 100644 --- a/core/lib/Drupal/Core/Installer/InstallerKernel.php +++ b/core/lib/Drupal/Core/Installer/InstallerKernel.php @@ -66,4 +66,10 @@ public function getInstallProfile() { return $profile; } + /** + * {@inheritdoc} + */ + public function getDistribution() { + return parent::getDistribution(); + } } diff --git a/core/modules/system/src/Tests/Installer/MultipleDistributionsProfileTest.php b/core/modules/system/src/Tests/Installer/MultipleDistributionsProfileTest.php index 9be2bd4..124e55f 100644 --- a/core/modules/system/src/Tests/Installer/MultipleDistributionsProfileTest.php +++ b/core/modules/system/src/Tests/Installer/MultipleDistributionsProfileTest.php @@ -84,7 +84,12 @@ public function testInstalled() { // Test that a site will multiple distributions will get an exception when // calling \Drupal\Core\DrupalKernel::getDistribution(). try { - $this->container->get('kernel')->getDistribution(); + $kernel = $this->container->get('kernel'); + // getDistribution() is protected in the DrupalKernel class. + // Call setAccessible(TRUE) so that we can call it to test its behavior. + $getDistributionMethod = new \ReflectionMethod($kernel, 'getDistribution'); + $getDistributionMethod->setAccessible(TRUE); + $getDistributionMethod->invokeArgs($kernel, array()); $this->fail('TooManyDistributionsException exception thrown.'); } catch (TooManyDistributionsException $e) {