Skip to content

Commit

Permalink
Allow auto drush aliases to be turned off via a feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
pjcdawkins committed Dec 12, 2023
1 parent c2e785b commit f13b9ce
Showing 3 changed files with 15 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config-defaults.yaml
Original file line number Diff line number Diff line change
@@ -87,6 +87,9 @@ application:
installer_url: null
manifest_url: null

# Enable auto-creating Drush aliases for Drupal environments.
drush_aliases: true

# Configuration for working with projects locally.
local:
local_dir: null # dynamically defaults to {service.project_config_dir}
8 changes: 5 additions & 3 deletions src/Command/CommandBase.php
Original file line number Diff line number Diff line change
@@ -236,9 +236,11 @@ protected function api()
$this->api
->dispatcher
->addListener('login_required', [$this, 'login']);
$this->api
->dispatcher
->addListener('environments_changed', [$this, 'updateDrushAliases']);
if ($this->config()->get('application.drush_aliases')) {
$this->api
->dispatcher
->addListener('environments_changed', [$this, 'updateDrushAliases']);
}
$this->apiHasListeners = true;
}

8 changes: 7 additions & 1 deletion src/Command/Local/LocalDrushAliasesCommand.php
Original file line number Diff line number Diff line change
@@ -35,7 +35,13 @@ public function isHidden()
return true;
}

// Hide this command in the list if the project is not Drupal.
// Only show this command if drush_aliases are enabled.
if (!$this->config()->get('application.drush_aliases')) {
return true;
}

// Hide the command in the list while in a project directory, if the
// project is not Drupal.
// Avoid checking if running in the home directory.
$projectRoot = $this->getProjectRoot();
if ($projectRoot && $this->config()->getHomeDirectory() !== getcwd() && !Drupal::isDrupal($projectRoot)) {

0 comments on commit f13b9ce

Please sign in to comment.