-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
74f3c36
commit 01b51ac
Showing
4 changed files
with
73 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
## About | ||
Provides an example implemention of events provided by DRS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"name": "example/example-drush-command", | ||
"description": "Example custom drush commands.", | ||
"keywords": [ | ||
"drush", | ||
"drupal" | ||
], | ||
"license": "GPL-2.0-or-later", | ||
"require": { | ||
"acquia/drupal-recommended-settings": "*" | ||
}, | ||
"autoload": { | ||
"psr-4": { | ||
"Example\\": "src" | ||
} | ||
}, | ||
"config": { | ||
"allow-plugins": { | ||
"acquia/drupal-recommended-settings": true | ||
} | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
examples/example-drush-command/src/Drush/Commands/ExampleDrushCommands.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
namespace Example\Drush\Commands; | ||
|
||
use Acquia\Drupal\RecommendedSettings\Drush\Commands\MultisiteDrushCommands; | ||
use Consolidation\AnnotatedCommand\CommandData; | ||
use Consolidation\AnnotatedCommand\Hooks\HookManager; | ||
use Drush\Attributes as CLI; | ||
use Drush\Commands\DrushCommands; | ||
|
||
/** | ||
* An example drush command file. | ||
*/ | ||
class ExampleDrushCommands extends DrushCommands { | ||
|
||
/** | ||
* Do not generate settings.php file to site1. | ||
*/ | ||
#[CLI\Hook(type: HookManager::ON_EVENT, target: MultisiteDrushCommands::VALIDATE_GENERATE_SETTINGS)] | ||
public function skipQuestionForSite(CommandData $commandData): bool { | ||
// DO NOT ask question for site: `site1`. | ||
if ($commandData->input()->getOption("uri") == "site1") { | ||
return FALSE; | ||
} | ||
return TRUE; | ||
} | ||
|
||
/** | ||
* Display successful message, after settings files are generated/updated. | ||
*/ | ||
#[CLI\Hook(type: HookManager::ON_EVENT, target: MultisiteDrushCommands::POST_GENERATE_SETTINGS)] | ||
public function showSuccessMessage(CommandData $commandData): void { | ||
$uri = $commandData->input()->getOption("uri"); | ||
$this->io()->info("The settings.php generated successfully for site `" . $uri . "`."); | ||
} | ||
|
||
} |