Skip to content

Commit

Permalink
ACMS-000: Use Drush::bootstrapManager() instead service.
Browse files Browse the repository at this point in the history
  • Loading branch information
chandan-singh7929 committed Mar 26, 2024
1 parent 2b0d670 commit 6a081e9
Showing 1 changed file with 3 additions and 17 deletions.
20 changes: 3 additions & 17 deletions src/Drush/Commands/MultisiteDrushCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Drush\Boot\BootstrapManager;
use Drush\Boot\DrupalBootLevels;
use Drush\Commands\DrushCommands;
use Drush\Drush;
use Psr\Container\ContainerInterface as DrushContainer;

/**
Expand All @@ -28,32 +29,17 @@ class MultisiteDrushCommands extends DrushCommands implements CustomEventAwareIn
const VALIDATE_GENERATE_SETTINGS = 'validate-generate-settings';
const POST_GENERATE_SETTINGS = 'post-generate-settings';

/**
* Construct an object of Multisite commands.
*/
public function __construct(private BootstrapManager $bootstrapManager) {
parent::__construct();
}

/**
* {@inheritDoc}
*/
public static function createEarly(DrushContainer $drush_container): self {
return new static(
$drush_container->get('bootstrap.manager')
);
}

/**
* Execute code before pre-validate site:install.
*/
#[CLI\Hook(type: HookManager::PRE_ARGUMENT_VALIDATOR, target: 'site-install')]
public function preValidateSiteInstall(CommandData $commandData): void {
$bootstrapManager = Drush::bootstrapManager();
if ($this->validateGenerateSettings($commandData)) {
// Get sites subdir which we set in the hook doGenerateSettings.
$sitesSubdir = $commandData->input()->getOption('sites-subdir');
// Try to get any already configured database information.
$this->bootstrapManager->bootstrapMax(DrupalBootLevels::CONFIGURATION, $commandData->annotationData());
$bootstrapManager->bootstrapMax(DrupalBootLevels::CONFIGURATION, $commandData->annotationData());
// By default, bootstrap manager boot site from default/setting.php
// hence remove the database connection if site is other than default.
if (($sitesSubdir && "sites/$sitesSubdir" !== $this->bootstrapManager->bootstrap()->confpath())) {
Expand Down

0 comments on commit 6a081e9

Please sign in to comment.