Skip to content

Commit

Permalink
Added drupal/console back to fixtures for Drupal 8 only.
Browse files Browse the repository at this point in the history
  • Loading branch information
TravisCarden committed Mar 16, 2020
1 parent 84aea64 commit 86d6607
Showing 1 changed file with 36 additions and 8 deletions.
44 changes: 36 additions & 8 deletions src/Fixture/FixtureCreator.php
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,14 @@ private function fixDefaultDependencies(): void {
$additions[] = 'drush/drush:dev-master || 10.x-dev || 9.x-dev || 9.5.x-dev';
}

// Add Drupal Console as a soft dependency akin to Drush.
$drupal_console_version = '~1.0';
if ($this->isDev) {
$drupal_console_version = 'dev-master';
if ($this->shouldRequireDrupalConsole()) {
// Add Drupal Console as a soft dependency akin to Drush.
$drupal_console_version = '~1.0';
if ($this->isDev) {
$drupal_console_version = 'dev-master';
}
$additions[] = "drupal/console:{$drupal_console_version}";
}
$additions[] = "drupal/console:{$drupal_console_version}";

// Install a specific version of Drupal core.
if ($this->drupalCoreVersion) {
Expand Down Expand Up @@ -472,6 +474,20 @@ private function fixDefaultDependencies(): void {
$this->processRunner->runOrcaVendorBin($command, $fixture_path);
}

/**
* Determines whether or not to require drupal/console.
*
* Only require it for Drupal 8. It's not compatible with Drupal 9 at the time
* of this writing.
*
* @return bool
* Returns TRUE if it should be required, or FALSE if not.
*/
private function shouldRequireDrupalConsole(): bool {
$version = $this->getResolvedDrupalCoreVersion();
return Comparator::lessThan($version, '9');
}

/**
* Determines whether or not to require drupal/core-dev.
*
Expand All @@ -482,16 +498,28 @@ private function fixDefaultDependencies(): void {
* Returns TRUE if it should be required, or FALSE if not.
*/
private function shouldRequireDrupalCoreDev(): bool {
$version = $this->getResolvedDrupalCoreVersion();
return Comparator::greaterThanOrEqualTo($version, '8.8');
}

/**
* Gets the concrete version of Drupal core that will be installed.
*
* @return string
* The best match for the requested version of Drupal core, accounting for
* ranges.
*/
private function getResolvedDrupalCoreVersion(): string {
try {
// Get the version if it's concrete as opposed to a range.
$version = $this->versionParser->normalize($this->drupalCoreVersion);
}
catch (\UnexpectedValueException $e) {
// The requested Drupal core version is a range. Get the best match.
$minimum_stability = $this->isDev ? 'dev' : 'stable';
$version = $this->coreVersionFinder->find($this->drupalCoreVersion, $minimum_stability);
$stability = $this->isDev ? 'dev' : 'stable';
$version = $this->coreVersionFinder->find($this->drupalCoreVersion, $stability, $stability);
}
return Comparator::greaterThanOrEqualTo($version, '8.8');
return $version;
}

/**
Expand Down

0 comments on commit 86d6607

Please sign in to comment.