Skip to content

Commit

Permalink
ACMS-3478: Updated README.md file.
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalkhode1 committed Jan 17, 2024
1 parent 74f3c36 commit 01b51ac
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 6 deletions.
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,23 @@ It allows your websites to be easily installed in both Acquia Cloud IDE & local
and deployable on Acquia Cloud.

## Installation
### Install using Composer
### Install using Composer

```
composer require acquia/drupal-recommended-settings
```
### Multi-site features with Acquia DRS
Acquia Global Commands comes in role to setup multi-site with Drupal Recommended Settings.

To setup a multi-site, please run below command.
The Drupal Recommended Settings offer the multi-site feature out of the box.
To configure a multi-site, run the following command, and the plugin will
automatically generate the settings.php in the backend.
```
drush site:install --uri site1
```

The plugin offers various events that allow you to implement custom logic based
on when these events are triggered. You can find the examples of such
implementations from [here](examples).

# Quick examples
## Generate settings for a given site
```
Expand All @@ -45,7 +49,8 @@ $settings = new Settings(DRUPAL_ROOT, $siteUri);
try {
// Call generate method.
$settings->generate();
} catch (SettingsException $e) {
}
catch (SettingsException $e) {
echo $e->getMessage();
}
```
Expand Down Expand Up @@ -83,7 +88,8 @@ $dbSpec = [
try {
// Call generate method passing database details.
$settings->generate($dbSpec);
} catch (SettingsException $e) {
}
catch (SettingsException $e) {
echo $e->getMessage();
}
```
Expand Down
2 changes: 2 additions & 0 deletions examples/example-drush-command/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
## About
Provides an example implemention of events provided by DRS.
22 changes: 22 additions & 0 deletions examples/example-drush-command/composer.json
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
}
}
}
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 . "`.");
}

}

0 comments on commit 01b51ac

Please sign in to comment.