Skip to content

Commit

Permalink
Dispatch GeneratorInfoAlter event (#6177)
Browse files Browse the repository at this point in the history
* Dispatch the GeneratorInfoAlter event

* Dispatch GeneratorInfoAlter event
  • Loading branch information
weitzman authored Dec 10, 2024
1 parent 3bd1fcf commit ec15d5d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/Commands/generate/ApplicationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ public function create(): Application
$application->setAutoExit(false);

$generators = $this->discover();
$application->addCommands($generators);
// Listen to this event in order to alter generator info.
$application->addCommands($application->dispatch(new GeneratorInfoAlter($generators))->generators);
// Hide default Symfony console commands.
foreach (['help', 'list', 'completion', '_complete'] as $name) {
$application->get($name)->setHidden(true);
Expand Down Expand Up @@ -90,11 +91,18 @@ public function filterClassExists(array $classes): array

/**
* Implements hook GeneratorInfoAlter.
*
* This gets called twice: first for the DCG core generators and then for all Drush+Drupal generators.
*/
public static function alterGenerators(GeneratorInfoAlter $event): void
{
$event->generators['theme-settings']->setName('theme:settings');
$event->generators['plugin-manager']->setName('plugin:manager');
// Alter DCG core generator names to match ours.
if (isset($event->generators['plugin-manager'])) {
$event->generators['plugin-manager']->setName('plugin:manager');
}
if (isset($event->generators['theme-settings'])) {
$event->generators['theme-settings']->setName('theme:settings');
}
}

public function logger(): LoggerInterface
Expand Down

0 comments on commit ec15d5d

Please sign in to comment.