Skip to content

Commit

Permalink
Directly add recipe command from Drupal 11 (#5997)
Browse files Browse the repository at this point in the history
* Directly add recipe command from Drupal 11

* phpcs
  • Loading branch information
weitzman committed May 12, 2024
1 parent e65b0d0 commit 0a32bbb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Boot/DrupalBoot8.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,10 @@ public function bootstrapDrupalFull(BootstrapManager $manager): void
$this->logger->debug(dt('Finished bootstrap of the Drupal Kernel.'));

parent::bootstrapDrupalFull($manager);

// Directly add the Drupal core bootstrapped commands.
Drush::getApplication()->addCommands($this->serviceManager->instantiateDrupalCoreBootstrappedCommands());

$this->addDrupalModuleDrushCommands($manager);

// Set a default account to make sure the correct timezone is set
Expand Down
22 changes: 22 additions & 0 deletions src/Runtime/ServiceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Consolidation\SiteAlias\SiteAliasManagerAwareInterface;
use Consolidation\SiteProcess\ProcessManagerAwareInterface;
use Drupal\Component\DependencyInjection\ContainerInterface as DrupalContainer;
use Drupal\Core\Recipe\RecipeCommand;
use DrupalCodeGenerator\Command\BaseGenerator;
use Drush\Attributes\Bootstrap;
use Drush\Boot\DrupalBootLevels;
Expand Down Expand Up @@ -290,6 +291,27 @@ public function instantiateYamlCliCommands(): array
return $instances;
}

/**
* Instantiate commands from Drupal Core that we want to expose
* as Drush commands.
*
* These require a bootstrapped Drupal.
*
* @return Command[]
* List of Symfony Command objects
*/
public function instantiateDrupalCoreBootstrappedCommands(): array
{
$instances = [];
if (class_exists(RecipeCommand::class)) {
$instance = new RecipeCommand($this->autoloader);
$instance->setHelp('See https://drupal.org/project/issues/drupal for bug reports and feature requests for this command.');
$instances[] = $instance;
}

return $instances;
}

/**
* Instantiate objects given a list of classes. For each class, if it has
* a static `create` factory, use that to instantiate it, passing both the
Expand Down

0 comments on commit 0a32bbb

Please sign in to comment.